5 Replies Latest reply on Jun 22, 2009 9:44 AM by wolfc

    Queue injection in JBoss 5 not working ?

      Hi all !
      I'm trying to inject a Queue as a @Resource into my EJB.

       @Stateless
       @WebService
      
       public class WebServiceBean implements EJBWebService {
      
       @Resource(mappedName="java:/ConnectionFactory")
       ConnectionFactory factory;
       @Resource(mappedName="queue/queue1")
       public static Queue queue;
      
       @WebMethod
       public void sendJMSMessage(String s) {
      
       ....
      
      
       }
      }


      The injection of the COnnectionFactory works fine, anyway the Queue injection issues an error when I try to access the WebService/EJB :

      Caused by: java.lang.NullPointerException
       at org.jboss.injection.lang.reflect.FieldBeanProperty.set(FieldBeanPrope
      rty.java:90)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.
      java:119)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.
      java:89)
       at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.
      java:61)
       at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionIn
      vocation.java:89)
       at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvo
      cation.java:83)
       at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invo
      ke(CurrentInvocationInterceptor.java:67)
       at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvo
      cation.java:74)
       at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1086)
      
       at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:83)
       at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
       at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:51)
       at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:53)
       at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:93)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(Stateles
      sInstanceInterceptor.java:58)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:102)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      


      Has anybody got an idea of what could be the problem ?
      thanks a lot in advance
      marco

        • 1. Re: Queue injection in JBoss 5 not working ?
          jaikiran

           

          @Resource(mappedName="queue/queue1")
          public static Queue queue;


          The spec does not allow injection on static fields:

          "EJB3 spec" wrote:
          The field or method may have any access qualifier (public, private, etc.) but must not be static.


          • 2. Re: Queue injection in JBoss 5 not working ?

            Hi jaikiran,
            thanks for your reply, anyway also with :

            @Resource(mappedName="queue/queue1")
            Queue queue;


            I get the same error......:-(
            from the stack track the error seems on the "set" field of the Resouce...I'll try injecting on the setter field now..........


            • 3. Re: Queue injection in JBoss 5 not working ?
              jaikiran

              Are you sure you are using JBoss-5 and also don't have any jboss specific jar files of older version? I remember there was a bug fix against JBossAS-4.x where a NullPointerException used to be thrown when actually a NameNotFoundExcepiton was the root cause.

              @Resource(mappedName="queue/queue1")


              So is queue/queue1 is being bound to JNDI? Can you please post the entire console (not server.log) logs and the queue configuration files?


              • 4. Re: Queue injection in JBoss 5 not working ?

                Also setter injection fails, yet with another stack trace (maybe more precise).

                java.lang.IllegalArgumentException: failed to inject JBossQueue[queue1] (implements [interface javax.jms.Queue]) from env/com.prix.WebServiceBean/queue (link -> queue/queue1) into com.prix.WebServiceBean.queue of com.prix.WebServiceBean@1c6b7df


                is it a Bug ?
                thanks
                marco

                • 5. Re: Queue injection in JBoss 5 not working ?
                  wolfc

                  It's a class loader issue.
                  The failure code handling in FieldBeanProperty is broken which results in a NPE.
                  The failure code handling in MethodBeanProperty isn't up to date, so gives an inconclusive message.

                  See also https://jira.jboss.org/jira/browse/EJBTHREE-1694

                  Please file a new Jira.