geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vamsavardhana Reddy" <c1vams...@gmail.com>
Subject Re: javamail
Date Thu, 02 Mar 2006 18:41:52 GMT
Alex,

There was a bug in Transport.send().  Transport.send(msg) problem is now
fixed.  See related JIRA GERONIMO-1669.

I wonder how it worked for you, pre GERONIMO-1669, without calling
transport.connect() explicitly.

-Vamsi

On 3/1/06, Alex Andrushchak <ustas@dekasoft.com.ua> wrote:
>
> Vamsi,
> Is this server 9.182.150.56 up?
> Is it possible to send mail throught it via standart mail client?
>
> 1. Try to set debug to your session.
>         session.setDebug(true);
> 2. Try to use addRecipients instead of  setRecipients:
>             ((MimeMessage) message).addRecipients(Message.RecipientType.TO,
> recipient);
>
> Best regards,
> Alex Andrushchak
>
> Vamsavardhana Reddy wrote:
>
> 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
>
> On 1/24/06, Alex Andrushchak <ustas@dekasoft.com.ua> wrote:
>
> > Hi!
>
> I have only application scope plan, but i think you can use it as start
> point for create your server scope plan:
>
> <application
>        xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"<http://geronimo.apache.org/xml/ns/j2ee/application>
>        configId="org/queryphone/Queryphone">
>
>     <dependency>
>         <uri>geronimo/geronimo-mail/1.0</uri>
>     </dependency>
>
>     <dependency>
>         <uri>geronimo/geronimo-javamail-transport/1.0</uri>
>     </dependency>
>
>     <gbean name="mail/MailSession" class="
> org.apache.geronimo.mail.MailGBean">
>         <attribute name="transportProtocol">smtp</attribute>
>         <attribute name="useDefault">false</attribute>
>         <attribute name="host">192.168.1.2</attribute>
>         <attribute name="properties">
>             mail.debug=true
>             mail.smtp.port=25
>             mail.from=queryphone-geronimo@dekasoft.com.ua
>         </attribute>
>     </gbean>
>
> </application>
>
>
> yskim@symcor.com wrote:
>
> Hello, could I have a good deployment plan XML file so that I can deploy
> mail in the server scope. I do not want to put the deployment part in
> geronimo-application.xml
> . I could find a sample deployment plan for javamail. Thanks, Young "Jakob
> Færch (Trifork)"
> <jrf@trifork.com> <jrf@trifork.com> To user@geronimo.apache.org 20/01/2006
> 12:55 cc PM Subject Re: javamail Please respond to user@geronimo.apa
> che.org Alex Andrushchak wrote:
>
> Ok, i've moved from dead point :-)
>
>      Wonderful!
>
>    Now i have another problem:
> Cannot send the message with MailerBean:java.lang.Exception: The message
> can not be send : Unable to locate provider for protocol: smtp
>
>  The transport for smtp is located in the file
> geronimo-1.0\repository\geronimo\jars\geronimo-javamail-transport-1.0.jar.
>
> By some odd mistake, it is not included in the tomcat distribution.
> If you are using a jetty distribution, the jar file should be there all
>
> right in GERONIMO_INSTALL_DIR/repository/geronimo/jars.
> If you are on a tomcat distribution, I _guess_ you would be fine
> downloading the jetty distribution and manually copying the jar file
> from the above directory in the jetty distribution to the same directory
>
>   in the tomcat distribution - anyone: feel free to correct me on this!
>
> In order to make the smtp transport available to your application, you
> need to add the following dependency to the application's plan:
>
> <dependency>
>      <groupId>geronimo</groupId>
>      <artifactId>geronimo-javamail-transport</artifactId>
>      <version>1.0</version>
> </dependency>
>
>
>    My application configuration is:
>    <gbean name="protocol.smtp"
> class="org.apache.geronimo.mail.SMTPTransportGBean">
>        <attribute name="host">
> 192.168.1.2</attribute>
>        <attribute name="port">25</attribute>
>        <attribute
> name="from">
> queryphone-geronimo@dekasoft.com.ua</attribute>      </gbean>
>
>    <gbean name="mail/MailSession"
> class="org.apache.geronimo.mail.MailGBean">
>        <attribute name="transportProtocol">smtp</attribute>
>
>        <attribute name="useDefault">true</attribute>
>        <attribute name="properties">mail.debug=true</attribute>
> <reference name="Protocols">
>            <name>
> protocol.smtp</name>
>        </reference>
>    </gbean>
>
>  It's not (yet) entirely well documented how to set up the necessary
> GBeans - to say the least.
> It seems in the AdventureBuilder (which is able to send mail using the
> smtp transport and javamail), the following GBean is sufficient:
>
>
> <gbean name="mail/MailSession" class="org.apache.geronimo.mail.MailGBean">
>          <attribute name="host">${smtpHost}</attribute>
>          <attribute name="properties">
>
>          mail.from=${smtpFrom}
>          mail.smtp.port=${smtpPort}</attribute>
> </gbean>
>
>
> Note that compared to you configuration, the smtp host and port is on
> the MailGBean, not the SMTPTransportGBean. I guess things will work with
>
> the SMTPTransportGBean configured alongside the MailGBean, but my
> experience was that the SMTPTransportGBean was not necessary - anyone:
> correct me on this!
>
> Alex, I hope this helps you; please keep the list updated on your progress.
>
>
> Jakob
>
>
>
>
>
>
>

Mime
View raw message