0 Replies Latest reply on Mar 9, 2012 9:24 AM by lkasprzy

    Dependency injection to Queue

    lkasprzy

      I have simple question, what I have to specify as name, mappedName and others parameters of @Resource annotation (javax.annotation.Resource), when i have queue defined in configuration(standalone-full.xml) ie:

       

                          <jms-queue name="testqueueName">

                              <entry name="testqueue"/>

                              <entry name="java:jboss/exported/jms/testqueue"/>

                          </jms-queue>

       

      Is some mapping beetwen arguments of @Resource and queue definition in xml ?

      Maybe is some way add some parameter tu jms-queue in xml witch tell that "this is my mappedName or name".

      I want to inject dependency in my Stateless bean.

      For example In weblogic adding:

       

        @Resource(mappedName="testqueue")

          protected javax.jms.Queue moneyTransferQueue;

       

      works fine.

       

       

      I have good working MDBean connected to this queue with annotation below(i put messages with remote client using lookup, not dependency injection):

       

      @MessageDriven(name = "HelloWorldMDB", mappedName="testqueue", activationConfig = {

                          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                          @ActivationConfigProperty(propertyName = "destination", propertyValue = "testqueue"),

                          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })

       

      In ActivationConfigProperty I  use just simple name "testqueue" without any prefixes and sufixes and it works great.

      When I use the same value as mappedName in @Resource there is an ERROR in jboss console:

       

       

      15:16:57,028 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was

      rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.

      context.java.comp.jboss-as-ejb-in-ear.jboss-as-ejb-in-ear.HelloWorldMDB.env.\"org.jboss.as.quickstarts.mdb.HelloWorldMDB\".moneyTransferQueu

      ejboss.naming.context.java.comp.jboss-as-ejb-in-ear.jboss-as-ejb-in-ear.HelloWorldMDB.env.testqueueMissing[jboss.naming.context.java.comp.jb

      oss-as-ejb-in-ear.jboss-as-ejb-in-ear.HelloWorldMDB.env.\"org.jboss.as.quickstarts.mdb.HelloWorldMDB\".moneyTransferQueuejboss.naming.contex

      t.java.comp.jboss-as-ejb-in-ear.jboss-as-ejb-in-ear.HelloWorldMDB.env.testqueue]"]}}}

       

       

      Btw. I have one application witch have to work in two other application servers - jboss 7.1 and weblogic 10  I use EJB 3.0, and dependency injection

      I try find that configuration, witch will be worked fine on both of this servers.

       

      I have attached ear with MDBean source (ejb-in-ear.zip), client source (JbossQueueSender.java).