0 Replies Latest reply on Jan 20, 2009 8:55 AM by grifoxx

    Reading email from my Inbox using MDB

    grifoxx
      I am trying to get my emails from my Inbox folder using MDB and MailListener interface. Just like the Seam Documentation says.

      This the code that I am using:

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

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

      @MessageDriven(activationConfig={
      @ActivationConfigProperty(propertyName="mailServer", propertyValue="pop.gmx.net"),
      @ActivationConfigProperty(propertyName="mailFolder", propertyValue="inbox"),
      @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
      @ActivationConfigProperty(propertyName="userName", propertyValue="email@gmx.de"),
      @ActivationConfigProperty(propertyName="password", propertyValue="password"),
      @ActivationConfigProperty(propertyName="debug", propertyValue="true")
      })
      @ResourceAdapter("mail-ra.rar")
      @Name("mailListener")
      public class TicketingMailListener implements MailListener {

      @Logger
      private Log log;
         public TicketingMailListener()
      {
        System.out.println("Into the constructor");
      }
         public void onMessage(Message arg0) {
        try {
         log.info("RECIEVED: " + arg0 + " --- SUBJECT: " + arg0.getSubject());
         System.out.println("RECIEVED: " + arg0 + " --- SUBJECT: " + arg0.getSubject());
        } catch (MessagingException e) {
         e.printStackTrace();
        }
      }

      }
      `

      I have also this in my components.xml file:

      `
      <mail:mail-session session-jndi-name="java:/Mail"></mail:mail-session>
      `

      When I try to debug the onMessage method nothing happens it just does not get in. And when I run the server it connects to the pop server but I cannot get the message. Instead it deletes the message.

      This is what I get when I run the JBoss:

      13:01:24,218 INFO [STDOUT] DEBUG: JavaMail version 1.4ea
      13:01:24,218 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.providers (The system cannot find the file specified)
      13:01:24,218 INFO [STDOUT] DEBUG: !anyLoaded
      13:01:24,218 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
      13:01:24,218 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
      13:01:24,218 INFO [STDOUT] DEBUG: Tables of loaded providers
      13:01:24,218 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]}
      13:01:24,234 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]}
      13:01:24,234 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
      13:01:24,234 INFO [STDOUT] DEBUG: !anyLoaded
      13:01:24,234 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.address.map
      13:01:24,234 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.6.0_10\jre\lib\javamail.address.map (The system cannot find the file specified)
      13:01:24,234 INFO [STDOUT] DEBUG: setDebug: JavaMail version 1.4ea
      13:01:24,234 INFO [STDOUT] DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]
      13:01:24,296 INFO [STDOUT] DEBUG POP3: connecting to host "pop.gmx.net", port 110, isSSL false
      13:01:24,375 INFO [STDOUT] S: +OK GMX POP3 StreamProxy ready <17372.1232366456@mp053>
      13:01:24,375 INFO [STDOUT] C: USER email@gmx.de
      13:01:24,390 INFO [STDOUT] S: +OK May I have your password, please?
      13:01:24,390 INFO [STDOUT] C: PASS password
      13:01:24,453 INFO [STDOUT] S: +OK Mailbox locked and ready
      13:01:24,468 INFO [STDOUT] C: STAT
      13:01:24,484 INFO [STDOUT] S: +OK 1 8684
      13:01:24,484 INFO [STDOUT] C: NOOP
      13:01:24,500 INFO [STDOUT] S: +OK
      13:01:24,531 INFO [STDOUT] C: NOOP
      13:01:24,546 INFO [STDOUT] S: +OK
      13:01:24,546 INFO [STDOUT] C: DELE 1
      13:01:24,562 INFO [STDOUT] S: +OK Message 1 deleted
      13:01:24,562 INFO [STDOUT] C: QUIT
      13:01:24,578 INFO [STDOUT] S: +OK GMX POP3 server signing off
      13:01:24,578 INFO [STDOUT] DEBUG POP3: connecting to host "pop.gmx.net", port 110, isSSL false
      13:01:24,687 INFO [STDOUT] S: +OK GMX POP3 StreamProxy ready <29509.1232366456@mp055>
      13:01:24,687 INFO [STDOUT] C: USER email@gmx.de
      13:01:24,703 INFO [STDOUT] S: +OK May I have your password, please?
      13:01:24,703 INFO [STDOUT] C: PASS password
      13:01:24,734 INFO [STDOUT] S: +OK Mailbox locked and ready
      13:01:24,734 INFO [STDOUT] C: QUIT

      Am I missing something?
      I have been trying to get an answer on the web but I could not find anything. I have also that other people had the same problem and could not get the right answer to the problem.

      Can anybody help me.

      Thanks a lot