4 Replies Latest reply on Sep 24, 2008 9:38 PM by red247.matt.parker.cox.net

    MDB Queue Injection

    red247

      I have a JMX service that publishes messages to a queue, which is monitored by a MDB. The MDB will receive the message without any truoble. I use injection to reference a queue to publish a message back to the JMX service. The injected queue always comes up with a null pointer exception. Does anyone see something wrong with what I have listed below? TIA.


      components.xml section



         <jms:queue-connection queue-connection-factory-jndi-name="java:/JmsXA" />  
         <jms:managed-queue-sender name="corrConvQueue" auto-create="true" queue-jndi-name="queue/corrConvQueue"/>
         <jms:managed-queue-sender name="corrConvProcessedQueue" auto-create="true" queue-jndi-name="queue/corrConvProcessedQueue"/>



        
      MDB section



      @MessageDriven(name="CorrConvMDB", activationConfig = {          
                   @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                   @ActivationConfigProperty(propertyName="destination", propertyValue="queue/corrConvQueue")
               }
      )
               
      public class CorrConvMDB implements MessageListener {
      
              private static final Log log = LogFactory.getLog( CorrConvMDB.class );
              
              protected int numberCandidates = 0;
              
              @PersistenceContext
              EntityManager manager;
                      
              @In(required=true)
              protected transient QueueSession session;
              
              @In(required=true)
              protected transient QueueSender corrConvProcessedQueue;
      
      
      
              /**
               * 
               * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
               */
              @SuppressWarnings("unchecked")
              @TransactionAttribute(TransactionAttributeType.REQUIRED)
              public void onMessage(Message message) {
                      
                      ......create message......
                              
                          // Return the message to the manager.
                      corrConvProcessedQueue.send(message);                   
              }
      
      }
      


        • 1. Re: MDB Queue Injection
          red247

          I'm using JBoss 4.2.3GA, Seam 2.0.2SP1, and richfaces 3.2.1GA.


          Here is the error message



          14:56:07,963 ERROR [CorrConvMDB] java.lang.NullPointerException
          java.lang.NullPointerException
                  at com.itt.bap.dao.mdb.CorrConvMDB.onMessage(CorrConvMDB.java:130)
                  at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                  at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:101)
                  at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                  at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:597)
                  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                  at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                  at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(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 $Proxy164.onMessage(Unknown Source)
                  at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
                  at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:906)
                  at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
                  at org.jboss.mq.SpySession.run(SpySession.java:323)
                  at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
                  at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
                  at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
                  at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
                  at java.lang.Thread.run(Thread.java:619)


          • 2. Re: MDB Queue Injection
            jnusaira

            I was actually curious why you have them as transient?



            But fwiw ... if thats a complete code listing you havent made the MDB a seam component (ie no @Name annotation) that would definitely not allow the injection to happen.

            • 3. Re: MDB Queue Injection
              red247

              I tried the transient keyword, and a host of others, that came from other posts. I didn't think it would work either. But at this point, I was game to try just about anything to fix it.

              • 4. Re: MDB Queue Injection
                red247.matt.parker.cox.net

                Thanks. That seemed to do the trick.