4 Replies Latest reply on Apr 21, 2009 2:05 AM by Stuart Douglas

    Async Problem...

    John Public Newbie

      I am having trouble sending email asynchronously..


      My method is part of a conversation...
      It signals the end of the conversation.


      Please help me out..


      Regards,
      John


      Here is my code...



      components.xml
                  ....    
                  xmlns:async="http://jboss.com/products/seam/async"
                  .....
                  http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.1.xsd"
      
         <async:quartz-dispatcher/>




      Class Foo ....
      
              @End
           @Transactional
           public void confirm() {
              ......
              Barobj.sendEmail()
      




      class Bar....
      
             @Asynchrnous
             sendEmail() {
                 String result = Renderer.instance().render("/notifyByEmail.xhtml");
             }
      


        • 1. Re: Async Problem...
          John Public Newbie

          In my application.xml...


          I have added quartz as a module and it is in my EAR lib directory.




          application.xml
          
          
           <module>
                    <java>quartz.jar</java>
               </module>



          Here's the exception



          java.net.PlainSocketImpl.socketConnect(Native Method)
          java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
          java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
          java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
          java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
          java.net.Socket.connect(Socket.java:516)
          java.net.Socket.connect(Socket.java:466)
          com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
          com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
          com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
          com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
          javax.mail.Service.connect(Service.java:297)
          javax.mail.Service.connect(Service.java:156)
          javax.mail.Service.connect(Service.java:105)
          org.jboss.seam.mail.ui.UIMessage.encodeEnd(UIMessage.java:167)
          org.jboss.seam.ui.util.JSF.renderChild(JSF.java:181)
          org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
          org.jboss.seam.ui.facelet.RendererRequest.renderFacelet(RendererRequest.java:103)
          org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:73)
          org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43)




          • 2. Re: Async Problem...
            Ingo Jobling Master

            Hi, Only modules (war, jar etc) are added to application.xml.


            Remove this:


            application.xml
            <module>
                <java>quartz.jar</java>
            </module>



            Instead, copy quartz.jar to the lib folder of the ear.  You can do this by adding it to the deployed jars property file in the root of your project (assuming it was seam-genned), otherwise modify your build script as required.


            • 3. Re: Async Problem...
              John Public Newbie

              This is ehat the docs say...


              Another alternative is to use the open source Quartz library to manage asynchronous method. You need to bundle the Quartz library JAR (found in the lib directory) in your EAR and declare it as a Java module in application.xml. The Quartz dispatcher may be configured by adding a Quartz property file to the classpath. It must be named seam.quartz.properties. In addition, you need to add the following line to components.xml to install the Quartz dispatcher.


              Any JBoss Seam members... Can they comment?

              • 4. Re: Async Problem...
                Stuart Douglas Master

                You can do it either way, there is certainly nothing wrong with declaring it in application.xml. The problem is that your code cannot connect to the mail server.


                do you have:


                <mail:mail-session host="smtp.example.com"/>
                
                



                with host set to your mail server?