geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick McGuire (JIRA)" <...@geronimo.apache.org>
Subject [jira] Commented: (GERONIMO-1669) javamail Transport.send() is not issuing connect() on the transport before sending the message.
Date Thu, 02 Mar 2006 13:14:40 GMT
    [ http://issues.apache.org/jira/browse/GERONIMO-1669?page=comments#action_12368489 ] 

Rick McGuire commented on GERONIMO-1669:
----------------------------------------

Ah, sorry, I didn't read your earlier comment closely enough.  Yes, all of the module tests
pass for me, but I'm not sure I can explain why it is working for me and not for you.  InternetAddress().getLocalAddress()
depends on a number of session/system properties being set to resolve the address.  For some
reason, these are getting set properly for me automatically, but not for you.  Bruce Snyder
also has not had a problem with this.  Here is a short patch to the MimeMessageTest module
to explicitly configure some of the properties to remove the system setup dependencies to
the test. 

Index: src/test/java/javax/mail/internet/MimeMessageTest.java
===================================================================
--- src/test/java/javax/mail/internet/MimeMessageTest.java	(revision 381685)
+++ src/test/java/javax/mail/internet/MimeMessageTest.java	(working copy)
@@ -377,7 +377,9 @@
         myMap.addMailcap("text/plain;;    x-java-content-handler=" + MimeMultipartTest.DummyTextHandler.class.getName());
         myMap.addMailcap("multipart/*;;    x-java-content-handler=" + MimeMultipartTest.DummyMultipartHandler.class.getName());
         CommandMap.setDefaultCommandMap(myMap);
-        session = Session.getDefaultInstance(new Properties());
+        Properties props = new Properties();
+        props.put("mail.from", "tester@apache.org");
+        session = Session.getDefaultInstance(props);
     }
 
     protected void tearDown() throws Exception {


> 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


Mime
View raw message