6 Replies Latest reply on Jan 23, 2010 2:43 PM by sathish avunoori

    Receiving mail

    Erik Slagter Newbie
      I'm trying to receive e-mails in my seam application. I'm using Seam 2.0.2SP1 and Jboss 4.2.2GA.
      The problem is that my onMessage call in my message driven bean isn't called. My bean looks as the following:

      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.mail.Message;

      import org.jboss.annotation.ejb.ResourceAdapter;
      import org.jboss.resource.adapter.mail.inflow.MailListener;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.log.Log;

      @MessageDriven(activationConfig={
                @ActivationConfigProperty(propertyName="mailServer", propertyValue="pop3.mydomain.nl"),
                @ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
                @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
                @ActivationConfigProperty(propertyName="userName", propertyValue="myUser"),          
                @ActivationConfigProperty(propertyName="password", propertyValue="myPass")
      })


      @ResourceAdapter("mail-ra.rar")
      @Name("emailRetrieverMDB")
      public class MailListenerBean implements MailListener  {

           @Logger
           private Log log;

           @In(create=true)
           MailProcessor mailProcessor;
           
           public void onMessage(Message message) {
                // Process the message
                log.info("                        ");
                log.info("onMessage being called");
                log.info("                        ");
                System.out.println("on Message");
                mailProcessor.processMail(message);
           }
      }

      The funny thing is that when I sniff for TCP packets I see normal behaviour. I can connect with the mail server and am able to read the number of messages that are in the INBOX.

      Also in the logging of Jboss I see that the emailRetrieverMDB is initialized:
      [Component] Component: emailRetrieverMDB, scope: STATELESS, type: MESSAGE_DRIVEN_BEAN, class: nl.chess.pos.MailListenerBean, JNDI: pos/MailListenerBean/local

      Why isn't my onMessage(Message) function called at a new message?
        • 1. Re: Receiving mail
          Pete Muir Master

          Try looking at debug logging.

          • 2. Re: Receiving mail
            Erik Slagter Newbie
            The only remarkable log message is:

            '
            11:14:13,978 INFO  [STDOUT] DEBUG: JavaMail version 1.4ea
            11:14:13,978 INFO  [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_14\jre\lib\javamail.providers (The system cannot find the file specified)
            11:14:13,978 INFO  [STDOUT] DEBUG: !anyLoaded
            11:14:13,978 INFO  [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
            11:14:13,993 INFO  [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
            11:14:13,993 INFO  [STDOUT] DEBUG: Tables of loaded providers
            11:14:13,993 INFO  [STDOUT] DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
            11:14:13,993 INFO  [STDOUT] DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
            11:14:13,993 INFO  [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
            11:14:13,993 INFO  [STDOUT] DEBUG: !anyLoaded
            11:14:13,993 INFO  [STDOUT] DEBUG: not loading resource: /META-INF/javamail.address.map
            11:14:13,993 INFO  [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_14\jre\lib\javamail.address.map (The system cannot find the file specified)
            11:14:13,993 INFO  [MailService] Mail Service bound to java:/Mail
            ... SNIP ...
            11:14:14,353 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
            '
            I completely emptied my mail-service.xml file. I editted my components.xml and added

            <mail:mail-session host="172.17.10.203"
                      username="myUser"
                      password="myUser"
                      debug="true"/>
                      
                 <!--  <mail:mail-session session-jndi-name="java:/Mail">
                      </mail:mail-session>-->

            The funny thing is that the logging says 'Mail Service bound to java:/Mail, although I commented it in my components.xml...

            I still have communication with my mail server. The mailserver says it has mail to be read. Yet it isn't calling my MessageDrivenBean...

            • 3. Re: Receiving mail
              Erik Slagter Newbie

              Is there a reason why the extras folder is missing in the 2.0.2.SP1 release? This folder should contain a custom mail-ra.rar which should be better (as defined in the doc)...
              I'm currently using the mail-ra.rar provided by Jboss 4.2.2GA.

              • 4. Re: Receiving mail
                Pete Muir Master

                The one in JBoss 4.2 is very out of date.


                Use the one that comes with Seam. Seam 2.0.2.SP1 had a bug causing the extras folder to be missing. This was fixed in 2.0.3.CR1 IIRC.

                • 5. Re: Receiving mail
                  Erik Slagter Newbie

                  Ah man!!!


                  I enabled seam debugging and saw that my MailProcessor wasn't initialised properly. This made the bean fail.
                  I'm also using the newest version of the mail-ra library...

                  • 6. Re: Receiving mail
                    sathish avunoori Newbie

                    hi Erik Slagter,


                    i am new to seam,
                    i am also trying to configure mail-ra.rar for receiving mails.
                    i need configuration details. where should i configure mail-ra.rar resource adopter.
                    can you please show me the code snippets which are related to configure mail-ra.rar details in our  seam application.




                    i hope you can help me,
                    advance thanks for your helping,
                    regards
                    sathish