1 Reply Latest reply on Jun 27, 2008 10:58 AM by Adrian Brock

    EJB3 MDB error when reading a message in JBossMQ

    Fabien Coppens Newbie

      Hi. I'm using JBoss 4.2.2.GA with EJB3 MDBs and Spring to inject the MDB's business logic. I'm getting an error related to the MDB's lifecyle.
      Here's my MDB code :

      package com.acme.impl;
      
      
      import javax.annotation.Resource;
      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.ejb.MessageDrivenContext;
      import javax.interceptor.Interceptors;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;
      
      import com.acme.api.MDBDelegate;
      
      /**
       * @author fcoppens
       */
      
      @MessageDriven(name="QueueListenerMDB", activationConfig = {
       @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
       @ActivationConfigProperty(propertyName="destination", propertyValue="queue/testQueue")
      
      })
      @Interceptors(SpringBeanAutowiringInterceptor.class)
      public class QueueListenerMDB implements MessageListener {
      
       @Resource
       private MessageDrivenContext context;
      
       @Autowired
       private MDBDelegate delegate;
      
       public void onMessage(Message message) {
       delegate.onMessage(message);
       }
      }


      The MDB is deployed correctly on JBoss without any errors.
      When I post a message on the queue, here's the error stack I get :
      2008-06-15 17:47:06,843 ERROR [org.jboss.resource.adapter.jms.inflow.JmsServerSes sion] Unexpected error delivering message org.jboss.mq.SpyObjectMessage {
      Header {
      jmsDestination : QUEUE.testQueue
      jmsDeliveryMode : 2
      jmsExpiration : 0
      jmsPriority : 4
      jmsMessageID : ID:11-12135448268281
      jmsTimeStamp : 1213544826828
      jmsCorrelationID: null
      jmsReplyTo : null
      jmsType : null
      jmsRedelivered : false
      jmsProperties : {}
      jmsPropReadWrite: false
      msgReadOnly : true
      producerClientId: ID:11
      }
      }
      java.lang.RuntimeException: java.lang.NullPointerException
      at org.jboss.ejb3.interceptor.LifecycleInterceptorHan dler.postConstruct(LifecycleInterceptorHandler.jav a:113)
      at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJ BContainer.java:619)
      at org.jboss.ejb3.AbstractPool.create(AbstractPool.ja va:131)
      at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.jav a:141)
      at org.jboss.ejb3.stateless.StatelessInstanceIntercep tor.invoke(StatelessInstanceInterceptor.java:54)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
      at org.jboss.ejb3.mdb.MessagingContainer.localInvoke( MessagingContainer.java:249)
      at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy. delivery(MessageInflowLocalProxy.java:268)
      at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy. invoke(MessageInflowLocalProxy.java:138)
      at $Proxy197.onMessage(Unknown Source)
      at org.jboss.resource.adapter.jms.inflow.JmsServerSes sion.onMessage(JmsServerSession.java:178)
      at org.jboss.mq.SpyMessageConsumer.sessionConsumerPro cessMessage(SpyMessageConsumer.java:891)
      at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMess ageConsumer.java:170)
      at org.jboss.mq.SpySession.run(SpySession.java:323)
      at org.jboss.resource.adapter.jms.inflow.JmsServerSes sion.run(JmsServerSession.java:237)
      at org.jboss.resource.work.WorkWrapper.execute(WorkWr apper.java:204)
      at org.jboss.util.threadpool.BasicTaskWrapper.run(Bas icTaskWrapper.java:275)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Wo rker.run(PooledExecutor.java:756)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NullPointerException
      at org.jboss.mx.loading.RepositoryClassLoader.findCla ss(RepositoryClassLoader.java:630)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
      at org.jboss.mx.loading.RepositoryClassLoader.loadCla ssImpl(RepositoryClassLoader.java:474)
      at org.jboss.mx.loading.RepositoryClassLoader.loadCla ss(RepositoryClassLoader.java:415)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 99)
      at java.net.FactoryURLClassLoader.loadClass(URLClassL oader.java:579)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 99)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
      at org.springframework.util.ClassUtils.forName(ClassU tils.java:249)
      at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:381)
      at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1135)
      at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1102)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:386)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
      at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
      at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:217)
      at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:168)
      at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:885)
      at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.useBeanFactory(SingletonBeanFac toryLocator.java:397)
      at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.getBeanFactoryReference(SpringBe anAutowiringInterceptor.java:139)
      at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.getBeanFactory(SpringBeanAutowir ingInterceptor.java:120)
      at org.springframework.ejb.interceptor.SpringBeanAuto wiringInterceptor.autowireBean(SpringBeanAutowirin gInterceptor.java:100)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.ejb3.interceptor.LifecycleInvocationCont extImpl.proceed(LifecycleInvocationContextImpl.jav a:131)
      at org.jboss.ejb3.interceptor.LifecycleInterceptorHan dler.postConstruct(LifecycleInterceptorHandler.jav a:109)
      ... 18 more