You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "Jacek Laskowski (JIRA)" <de...@geronimo.apache.org> on 2006/03/02 13:10:22 UTC

[jira] Commented: (GERONIMO-1669) javamail Transport.send() is not issuing connect() on the transport before sending the message.

    [ http://issues.apache.org/jira/browse/GERONIMO-1669?page=comments#action_12368479 ] 

Jacek Laskowski commented on GERONIMO-1669:
-------------------------------------------

I was about to commit the patch, but was unable to pass the tests successfully (mvn test). The exception was:

javax.mail.MessagingException: No local address defined
        at javax.mail.internet.MimeMessage.setFrom(MimeMessage.java:298)
        at javax.mail.internet.MimeMessageTest.testFrom(MimeMessageTest.java:102)

Does the tests pass for you?

> javamail Transport.send() is not issuing connect() on the transport before sending the message.
> -----------------------------------------------------------------------------------------------
>
>          Key: GERONIMO-1669
>          URL: http://issues.apache.org/jira/browse/GERONIMO-1669
>      Project: Geronimo
>         Type: Bug
>   Components: mail
>     Versions: 1.x
>     Reporter: Rick McGuire
>  Attachments: GERONIMO-1669.patch
>
> This was reported on the geronimo user list (problem report attached below).  The error is occuring because the Transport.send() code is failing to surround the sendMessage() call with connect() and close() calls on the transport, resulting in the connection failure.  Additionally, this code is not properly merging send failures for multiple transports into a single SendFailedException with proper reporting of which addresses the message was not sent to. 
> Hi Alex,
> I am trying to send mail from a servlet.  Here is my geronimo-web.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1" configId="MailWebApp/MailWebApp">
>     <dependency>
>         <uri>geronimo/geronimo-mail/1.2-SNAPSHOT</uri>
>     </dependency>
>     <dependency>
>         <uri>geronimo/geronimo-javamail-transport/1.2-SNAPSHOT</uri>
>     </dependency>
>   <context-root>/MailWebApp</context-root>
>   <context-priority-classloader>false</context-priority-classloader>
>     <resource-ref>
>       <ref-name>mail/MailSession</ref-name>
>       <target-name>
>  geronimo.server:J2EEApplication=null,J2EEModule=MailWebApp/MailWebApp,J2EEServer=geronimo,j2eeType=JavaMailResource,name=MailSession
>       </target-name>
>     </resource-ref>
>    
>      <gbean name="MailSession" class="org.apache.geronimo.mail.MailGBean">
>         <attribute name="transportProtocol">smtp</attribute>
>          <attribute name="host">9.182.150.56</attribute>
>         <attribute name="useDefault">false</attribute>
>         <attribute name="properties">
>         mail.debug=true
>         mail.from=c1vamsi1c@gmail.com
>         mail.smtp.port=25</attribute>  
>      </gbean>
> </web-app>
> Here are the imports and the doGet() method in my servlet.
> import javax.mail.Session;
> import javax.mail.Transport;
> import javax.mail.Message.RecipientType;
> import javax.mail.internet.InternetAddress;
> import javax.mail.internet.MimeMessage;
>     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
>       
>         response.setContentType("text/plain");
>        
>         PrintWriter out = response.getWriter();
>        
>         try {
>             InitialContext ic = new InitialContext();
>            
>             Session mailSession = (Session) ic.lookup("java:comp/env/mail/MailSession");
>             mailSession.setDebug(true);
>             mailSession.setDebugOut(System.err);
>             out.println("session = "+mailSession);
>            
>             MimeMessage msg = new MimeMessage(mailSession);
>            
>             msg.setRecipients(RecipientType.TO, new InternetAddress[] {new InternetAddress("c1vamsi1c@gmail.com")});
>            
>             msg.setSubject("Mail sent by MailerServlet");
>            
>             msg.setText("Hello");
>            
>             msg.setFrom(InternetAddress.getLocalAddress(mailSession));
>              
>              Transport.send(msg);
>         } catch (Exception e) {
>             e.printStackTrace(out);
>         }
>     }                     
> When I access the servlet, I am getting the following Exception.
> java.lang.IllegalStateException: Not connected
> 	at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SMTPTransport.java:356)
> 	at javax.mail.Transport.send(Transport.java:80)
> 	at javax.mail.Transport.send
> (Transport.java:46)
> 	at mailwebapp.MailerServlet.doGet(MailerServlet.java:64)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
> 	at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke
> (StandardWrapperValve.java:213)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> 	at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:46)
> 	at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:273)
> 	at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:31)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> 	at org.apache.catalina.core.StandardEngineValve.invoke
> (StandardEngineValve.java:107)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> 	at org.apache.coyote.http11.Http11Processor.process
> (Http11Processor.java:869)
> 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
> 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java
> :527)
> 	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
> 	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> 	at java.lang.Thread.run
> (Unknown Source)
> Any guesses on what I am doing differently?
> Thanks,
> Vamsi

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira