tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Georgopoulos (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-1697) javamail: sending email fails
Date Thu, 01 Sep 2016 20:57:20 GMT

    [ https://issues.apache.org/jira/browse/TOMEE-1697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15456587#comment-15456587
] 

George Georgopoulos commented on TOMEE-1697:
--------------------------------------------

Hi, 

I changed my configuration from:
{code:xml}
	<Resource id="mail/Default" type="javax.mail.Session">
		mail.transport.protocol=smtp 
		mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory 
		mail.smtp.socketFactory.fallback=false 
		mail.smtp.host=smtp.gmail.com 
		mail.smtp.port=465 
		mail.smtp.auth=true 
		mail.smtp.user=xxxxxxxx@arkasoft.com
		password=xxxxxxxx
	</Resource>
{code}
which was working for TomEE-1.7.1 and 1.7.2 to:
{code:xml}
	<Resource id="mail/Default" type="javax.mail.Session">
		mail.transport.protocol=smtp
		mail.smtp.host=smtp.gmail.com
		mail.smtp.host=smtp.gmail.com
		mail.smtp.port=587
		mail.smtp.auth=true
		mail.smtp.starttls.enable=true
		mail.smtp.user=xxxxxxxx@arkasoft.com
		password=xxxxxxxx
	</Resource>
{code}
for TomEE-1.7.4 and it works (no code changes).

Notice the port number change.

> javamail: sending email fails
> -----------------------------
>
>                 Key: TOMEE-1697
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1697
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.7.3
>         Environment: Linux (Ubuntu 14.04.3 LTS), Oracle Java 1.8.0_66
>            Reporter: Tamás Greguss
>             Fix For: 7.0.2
>
>
> Sending email fails. javamail's Transport.send(...) function throws an exception. The
same code works fine with previous versions of TomEE which includes javamail 1.8.3. But TomEE
1.7.3 upgraded to javamail 1.9.0-alpha2 which does not work well.
> If in TomEE 1.7.3 lib folder I change the content of geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar
file to the previous geronimo-javamail_1.4_mail-1.8.3.jar, it also works well.
> Here is the code that works fine with sendmail 1.8.3 in TomEE 1.7.1 but fails with sendmail.1.9.0-alpha2
in TomEE 1.7.3:
>  (This is a low level code only. But using apache commons email library which uses java.mail
in the background, also fails.)
> {code:title=MailSender.java|borderStyle=solid}
> public static void SendWithGMailSSL( String email_to, String subject, String text, String
email_from, final String senderuser, final String senderpass ) {
> 	Properties props = new Properties();
> 	props.put("mail.smtp.host", "smtp.gmail.com");
> 	props.put("mail.smtp.socketFactory.port", "465");
> 	props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
> 	props.put("mail.smtp.auth", "true");
> 	props.put("mail.smtp.port", "465");
> 	Session session;
> 	try {
> 		session = Session.getInstance(props, new javax.mail.Authenticator() {
> 			@Override
> 			protected PasswordAuthentication getPasswordAuthentication() {
> 				return new PasswordAuthentication(senderuser, senderpass);
> 			}
> 		});
> 	} catch (Exception e) {
> 		throw new RuntimeException(e);
> 	}
> 	try {
> 		Message message = new MimeMessage(session);
> 		message.setFrom(new InternetAddress(email_from));
> 		message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email_to));
> 		message.setSubject(subject);
> 		message.setText(text);
> 		Transport.send(message);
> 		//System.out.println("e-mail sending done.");
> 	} catch (MessagingException e) {
> 		throw new RuntimeException(e);
> 	}
> }
> {code}
> The calling of Transport.send(message) throws an exception:
> {noformat}
> javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Connection
error (java.io.IOException: Error connecting to smtp.gmail.com, 465))
> 	at javax.mail.Transport.send(Transport.java:163)
> 	at javax.mail.Transport.send(Transport.java:48)
> 	at com.gbit.lib.GBITMail.SendWithGMailSSL(GBITMail.java:136)
> 	at com.gbit.lib.GBITMail.SendMail(GBITMail.java:103)
> 	at com.gbit.efoglalo.test.UnitTestMB.testSendingEmailOld(UnitTestMB.java:503)
> 	at com.gbit.efoglalo.test.UnitTestMB$$OwbNormalScopeProxy0.testSendingEmailOld(com/gbit/efoglalo/test/UnitTestMB.java)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
> 	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
> 	at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
> 	at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:88)
> 	at javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
> 	at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:420)
> 	at javax.faces.component.UICommand.broadcast(UICommand.java:103)
> 	at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1041)
> 	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:289)
> 	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1415)
> 	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:765)
> 	at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
> 	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
> 	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
> 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> 	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> 	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> 	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
> 	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
> 	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
> 	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
> 	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> 	at org.omnifaces.filter.CacheControlFilter.doFilter(CacheControlFilter.java:226)
> 	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
> 	at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
> 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
> 	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: javax.mail.MessagingException: Connection error (java.io.IOException: Error
connecting to smtp.gmail.com, 465)
> 	at org.apache.geronimo.javamail.transport.smtp.SMTPConnection.protocolConnect(SMTPConnection.java:166)
> 	at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:165)
> 	at javax.mail.Service.connect(Service.java:274)
> 	at javax.mail.Service.connect(Service.java:91)
> 	at javax.mail.Service.connect(Service.java:76)
> 	at javax.mail.Transport.send(Transport.java:94)
> 	... 59 more
> Caused by: java.io.IOException: Error connecting to smtp.gmail.com, 465
> 	at org.apache.geronimo.javamail.util.MailConnection.createSocketFromFactory(MailConnection.java:408)
> 	at org.apache.geronimo.javamail.util.MailConnection.createSocket(MailConnection.java:504)
> 	at org.apache.geronimo.javamail.util.MailConnection.getConnectedSocket(MailConnection.java:322)
> 	at org.apache.geronimo.javamail.util.MailConnection.getConnection(MailConnection.java:274)
> 	at org.apache.geronimo.javamail.transport.smtp.SMTPConnection.protocolConnect(SMTPConnection.java:145)
> 	... 64 more
> Caused by: java.lang.InstantiationException
> 	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
> 	at java.lang.Class.newInstance(Class.java:442)
> 	at org.apache.geronimo.javamail.util.MailConnection.createSocketFromFactory(MailConnection.java:355)
> 	... 68 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message