3 Replies Latest reply on Mar 15, 2007 7:16 PM by Bradley Smith

    Email Listening MDB Accessing Seam Components

    Dave Everson Newbie

      We are getting a Null Pointer Exception in an MDB that is listening for emails.

      It appears that the Seam components are not being properly injected. We get errors when we attempt to use @Logger. We have changed these for the time being to System.out.printlns. Our service EJB components are not getting injected either.

      Our environment is Seam 1.1.7RC1, JBoss 4.0.5. The mail-ra.rar file has been placed in the server\default\deploy folder.

      The following is our MDB that is throwing the NPEs:

      package us.crimnet.iss.listeners;
      
      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.ejb.Stateless;
      import javax.mail.Message;
      
      import org.jboss.annotation.ejb.ResourceAdapter;
      import org.jboss.mail.MailException;
      
      import org.jboss.resource.adapter.mail.inflow.MailListener;
      import org.jboss.seam.Component;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.ScopeType;
      
      import us.crimnet.iss.services.HistoryManagement;
      import us.crimnet.iss.services.impl.HistoryManagementImpl;
      
      @MessageDriven(activationConfig={
       @ActivationConfigProperty(propertyName="mailServer", propertyValue="domain.com"),
       @ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
       @ActivationConfigProperty(propertyName="storeProtocol", propertyValue="pop3"),
       @ActivationConfigProperty(propertyName="userName", propertyValue="uid"),
       @ActivationConfigProperty(propertyName="password", propertyValue="pwd")
      })
      
      @ResourceAdapter("mail-ra.rar")
      @Name("requestEmailListener")
      
      public class RequestEmailListener implements MailListener {
      
       @In(create=true)
       private HistoryManagement historyManagement;
      
       public void onMessage(Message message) {
       System.out.println("Can we inject the @Logger here???");
       System.out.println("RequestEmailListener.onMessage()");
       try {
       Long id = Long.parseLong(message.getSubject());
       System.out.println("History id [" + id + "]");
       //TODO : dj : The following line threw an NPE
       // was it not properly injected by Seam?
       historyManagement.sendRequest(id);
      
       System.out.println("back from HistoryManagement");
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
      }
      


      Any suggestions as to what the causing the Seam Components not to be injected or initialized?

      Thanks!