0 Replies Latest reply on Mar 17, 2007 7:02 AM by Alessandro Ilardo

    MDB @PostConstruct error

    Alessandro Ilardo Newbie

      Hi there,
      I'm trying to run a sample MDB which should send emails.
      Jboss 4.0.5 GA - EJB3

      I can correctly deploy the EJB Module,
      10:28:17,683 INFO [Ejb3Deployment] EJB3 deployment time took: 26
      10:28:17,692 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Mail-EJBModule.jar,name=MailMDB,service=EJB3 with dependencies:
      10:28:17,722 INFO [EJBContainer] STARTED EJB: eu.virtualLab.mail.MailMDB ejbName: MailMDB
      10:28:17,725 WARN [MessagingContainer] Could not find the queue destination-jndi-name=queue/outGoingEmail
      10:28:17,727 WARN [MessagingContainer] destination not found: queue/outGoingEmail reason: javax.naming.NameNotFoundException: outGoingEmail not bound
      10:28:17,729 WARN [MessagingContainer] creating a new temporary destination: queue/outGoingEmail
      10:28:17,762 INFO [outGoingEmail] Bound to JNDI name: queue/outGoingEmail
      10:28:17,854 INFO [EJB3Deployer] Deployed: file:/etc/jboss-4.0.5.GA/server/default/deploy/Mail-EJBModule.jar
      11:27:17,659 INFO [Ejb3Deployment] EJB3 deployment time took: 66
      11:27:17,670 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Mail-EJBModule.jar,name=MailMDB,service=EJB3 with dependencies:
      11:27:17,712 INFO [EJBContainer] STARTED EJB: eu.virtualLab.mail.MailMDB ejbName: MailMDB
      11:27:17,760 INFO [EJB3Deployer] Deployed: file:/etc/jboss-4.0.5.GA/server/default/deploy/Mail-EJBModule.jar

      but I can't run it from a Client, belowe the stack trace from JBoss
      11:38:55,699 INFO [ClientDeployer] Removing client ENC from: Mail-EJBModuleClient
      11:38:55,737 INFO [ClientDeployer] Client ENC bound under: Mail-EJBModuleClient
      11:38:56,686 ERROR [JmsServerSession] Unexpected error delivering message org.jboss.mq.SpyObjectMessage {
      Header {
      jmsDestination : QUEUE.outGoingEmail
      jmsDeliveryMode : 2
      jmsExpiration : 0
      jmsPriority : 4
      jmsMessageID : ID:9-11741279366781
      jmsTimeStamp : 1174127936678
      jmsCorrelationID: null
      jmsReplyTo : null
      jmsType : null
      jmsRedelivered : false
      jmsProperties : {sent=1174127936673}
      jmsPropReadWrite: false
      msgReadOnly : true
      producerClientId: ID:9
      java.lang.RuntimeException: java.lang.NullPointerException
      at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:113)
      at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:505)
      at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:112)
      at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.java:122)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)

      The client code is
      QueueConnection cnn = null;
       QueueSender sender = null;
       QueueSession sess = null;
       Queue queue = null;
       try {
       InitialContext ctx = new InitialContext();
       queue = (Queue) ctx.lookup("queue/outGoingEmail");
       QueueConnectionFactory factory =
       (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
       cnn = factory.createQueueConnection();
       sess = cnn.createQueueSession(false,
       EmailBody email = new EmailBody(new String[]{"sandro@my-domain.net"},
       "test MailMDB module", "test MailMDB module");
       ObjectMessage msg = sess.createObjectMessage();
       // The sent timestamp acts as the message's ID
       long sent = System.currentTimeMillis();
       msg.setLongProperty("sent", sent);
       sender = sess.createSender(queue);
       // sess.commit ();
       } catch (JMSException ex) {
       } catch (Exception e) {

      and the MDB
      @MessageDriven(mappedName = "jms/MailMDB", activationConfig = {
       @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(propertyName="destination", propertyValue="queue/outGoingEmail")
      public class MailMDB implements MessageListener {
       private SessionContext context;
       private javax.mail.Message msg = null;
       Properties htmlTags = new Properties();
       private final Logger logger = Logger.getLogger(getClass().getName());
       public void initialize() {
       logger.info("[initialize] PostConstruct. ok!");
       Session session =(Session)context.lookup("java:comp/env/mail/Mail");
       logger.info("[initialize] Mail Factory session from app. server. ok!");

      from the logger the code seems to break off in the line where it try to get a Mail session.
      What's my mistake here?
      Thank you in advance.