1 2 Previous Next 15 Replies Latest reply on Sep 4, 2013 2:55 PM by billhmoore

    ejb-jar.xml and MDB

    billhmoore

      I had the following annotations in my MDB:

       

      @MessageDriven(name = "AccountTransferOutboundMDB",

              activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),

                      @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/topic/whm_dev_ATROutboundTopic"),

                      @ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable"),

                      @ActivationConfigProperty( propertyName="clientID", propertyValue="MYCATR"),

                      @ActivationConfigProperty( propertyName="subscriptionName", propertyValue="ATROutbound"),

                      @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),

                      @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=168.179.60.173;port=5445")

              })

       

      These annotation are working.

       

      Now I moved them to an ejb-jar.xml, as follows:

       

      <message-driven>

          <ejb-name>AccountTransferOutboundMDB</ejb-name>

          <ejb-class>gov.utah.dts.messageDrivenBean.AccountTransferOutboundMDB</ejb-class>

           <transaction-type>Bean</transaction-type>

           <message-destination-type>javax.jms.Topic</message-destination-type>

         <activation-config>

            <activation-config-property>

                    <activation-config-property-name>destinationType</activation-config-property-name>

                    <activation-config-property-value>javax.jms.Topic</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>destination</activation-config-property-name>

                    <activation-config-property-value>java:/topic/whm_dev_ATROutboundTopic</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>subscriptionDurability</activation-config-property-name>

                    <activation-config-property-value>Durable</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>clientID</activation-config-property-name>

                    <activation-config-property-value>MYCATR</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>subscriptionName</activation-config-property-name>

                    <activation-config-property-value>ATROutbound</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>connectorClassName</activation-config-property-name>

                  <activation-config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</activation-config-property-value>

            </activation-config-property>

            <activation-config-property>

                  <activation-config-property-name>connectionParameters</activation-config-property-name>

                  <activation-config-property-value>host=168.179.60.173;port=5445</activation-config-property-value>

            </activation-config-property>

          </activation-config>

       

      </message-driven>

       

      When I run I am getting the following error which indicates the ejb-jar.xml is not being picked up:

      Caused by: javax.resource.spi.InvalidPropertyException: Destination is mandatory

       

      I am missing something but I have no idea what?

        • 1. Re: ejb-jar.xml and MDB
          billhmoore

          I have seem some information which points to having a jboss.xml.  I don't have one.  Is the jboss.xml required for JBOSS AS7?

          • 2. Re: ejb-jar.xml and MDB
            billhmoore

            I have tried many things and nothing is working.

             

            At a minimum I must be able to externalize the following properties from the code, mainly to avoid having to recompile as we move from one environment to another:

             

                            @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/topic/whm_dev_ATROutboundTopic"),

                            @ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable"),

                            @ActivationConfigProperty( propertyName="clientID", propertyValue="MYCATR"),

                            @ActivationConfigProperty( propertyName="subscriptionName", propertyValue="ATROutbound"),

                            @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),

                            @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=168.179.60.173;port=5445")

             

            Any suggestion would be appreciated, thanks in advance.

            • 3. Re: ejb-jar.xml and MDB
              jbertram

              Can you attach your MDB jar?

              • 4. Re: Re: ejb-jar.xml and MDB
                billhmoore

                Here is the jar

                • 5. Re: Re: ejb-jar.xml and MDB
                  jbertram

                  Where is your ejb-jar.xml?  The directory mdb.jar/META-INF doesn't contain ejb-jar.xml.  I'd say that is your problem.  The MDB has to be packaged properly to deploy properly.

                  • 6. Re: ejb-jar.xml and MDB
                    billhmoore

                    I had renamed it to jboss.xml

                    • 7. Re: ejb-jar.xml and MDB
                      jbertram

                      The file jboss.xml is not in mdb.jar/META-INF.  It's in mdb.jar/WebContent/META-INF/ which is incorrect.  As I said, the MDB has to be packaged properly to deploy properly.

                      • 8. Re: ejb-jar.xml and MDB
                        billhmoore

                        Should I be creating a separate jar file for the MessageDrivenBean? 

                         

                        I am actually creating a war file which then deployed to a JBOSS AS7.

                         

                        When deployed with the @ActivationConfigProperty in the MDB - AccountTransferOutboundMDB, then I can send messages from some test code and the MDB is executed.

                         

                        However, when I try to use the ejb-jar.xml, the destination is not found.

                        • 9. Re: Re: ejb-jar.xml and MDB
                          billhmoore

                          I have the actual war file which I am using under jboss.

                          • 10. Re: Re: ejb-jar.xml and MDB
                            jbertram

                            EJB 3.1 added the ability to deploy an EJB (in your case an MDB) within a WAR, but I'm not terribly familiar with that feature since I haven't personally used it.  It's possible that the container isn't deploying your MDB because you're using the EJB 3.0 schema in your ejb-jar.xml instead of EJB 3.1 whereas when you use annotations it assumes it is 3.1.  However, that's just a guess.

                             

                            My recommendation would be to deploy your MDB in its own JAR file.

                            1 of 1 people found this helpful
                            • 11. Re: Re: Re: ejb-jar.xml and MDB
                              billhmoore

                              I have create a new sample set of projects, one project is a jar for the mdb and the xml file.  The other is a sender client as war file. Both are being deployed in a single JBOSS AS7 server with HornetQ.

                               

                              If I use the @ActivationConfigProperty in the MDB code then all works.

                               

                              But if I move the destinationType and destination to an ejb-jar.xml, then I get the following error:

                               

                              Caused by: javax.resource.spi.InvalidPropertyException: Destination is mandatory

                               

                              I am deploying the jar and

                              • 12. Re: ejb-jar.xml and MDB
                                jaikiran

                                You have the ejb-jar.xml in the .war at the wrong place. The spec says:

                                 

                                In a .war file, the deployment descriptor is stored with the name WEB-INF/ejb-jar.xml

                                • 13. Re: ejb-jar.xml and MDB
                                  arun168403
                                  • 14. Re: ejb-jar.xml and MDB
                                    jbertram

                                    I took Employee.jar from the MDBWebClient.zip and deployed it to a fresh instance of JBoss EAP 6.1.  Once I created the proper JMS destination it deployed fine:

                                    08:52:57,202 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "Employee.jar" (runtime-name: "Employee.jar")

                                    ...

                                    08:52:59,256 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 59) JBAS011601: Bound messaging object to jndi name java:/queue/testQueue

                                    ...

                                    08:52:59,328 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 32) JBAS018559: Deployed "Employee.jar" (runtime-name : "Employee.jar")

                                    08:52:59,343 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) JBAS014142: Started message driven bean 'QueueListenerMDB' with 'hornetq-ra' resource adapter

                                     

                                    This is the destination I created:

                                       <jms-destinations>

                                           <jms-queue name="testQueue">

                                               <entry name="java:/queue/testQueue"/>

                                           </jms-queue>

                                       </jms-destinations>

                                     

                                    At this point I'm not sure what you're doing wrong.

                                    1 2 Previous Next