2 Replies Latest reply on Sep 17, 2003 7:19 AM by marks

    correct entries in ejb-jar.xml and jboss.xml for a MDB

    marks Newbie

      I am deploying a test message driven bean on a JBoss 3.2.1 running on Red Hat 8.0 machine.

      The entries of my ejb-jar.xml look like below:

      <ejb-jar>
      <enterprise-beans>
      <message-driven>
      <ejb-name>TestMyBean</ejb-name>
      <ejb-class>com.me.ejb.TestMyBean</ejb-class>
      <message-selector></message-selector>
      <transaction-type>Bean</transaction-type>
      <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
      <message-driven-destination>
      <destination-type>javax.jms.Queue</destination-type>
      <subscription-durability>NonDurable</subscription-durability>
      </message-driven-destination>
      </message-driven>
      </enterprise-beans>
      </ejb-jar>

      and the jboss.xml entries look like below:


      <enterprise-beans>
      <message-driven>
      <ejb-name>TestMyBean</ejb-name>
      <configuration-name>Standard Message Driven Bean</configuration-name>
      <destination-jndi-name>queue/TestMyQueue</destination-jndi-name>
      </message-driven>
      </enterprise-beans>


      and I do define a queue called TestMyQueue in the jbossmq-destinations-service.xml file as below:


      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager


      Am I missing any entries?

      The problem in my case is that the TestMyBean does not get the JMS messages sent by the client ( a servlet running on Tomcat on a different machine ).

      Some articles online talk about a <resource-ref> tag to be used with the ejb-jar.xml file. Is there any pointer to a EJB doc/spec that governs the use of these tags? I looked in the EJB spec and did not find anything there.

      ms

        • 1. Re: correct entries in ejb-jar.xml and jboss.xml for a MDB
          Stephane Nicoll Master

          Why do you put bean managed transaction in your MDB?
          You don't need to set the configuration name in jboss.xml if you want to use the default one. The queue definition seems ok.

          1/ Is your servlet is able to send message to this queue.?

          2/ Check with the JMX console that TestMyQueue exists and that there are messages in there (http://jbosshost:8080/jmx-console see the jboss.mq.destinations domain)

          3/ When deploying your ejb-jar is it ok? Can you see the TestMyBean in the jmx console?

          4/ What is the code of your bean? (onMessage)

          Regards,

          Stephane



          • 2. Re: correct entries in ejb-jar.xml and jboss.xml for a MDB
            marks Newbie

            Thanks for the suggestions. I managed to get rid of all problems ( and I must saymost of them were mainly self created ).

            1) The directory structure of the bean was all wrong. The O'Reilly EJB book ( 2nd Ed covering EJB 1.1 ) had me layout the directory structure as below:

            com
            ----me
            -------ejb
            ----------TestMyBean.java
            ----------META-INF
            ---------------ejb-jar.xml
            ---------------jboss.xml

            which is wrong...moving the META-INF to be at the same level as com made things OK.

            I also added this line to the ejb-jar.xml in the <message-driven> part

            <resource-env-ref>
            <resource-env-ref-name>queue/TestMyQueue</resource-env-ref-name>
            <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
            </resource-env-ref>

            Is the above required? The deployment process would complain for the above line, so I put it in.

            and a whole section on <assembly-descriptor> ( I thought this was optional, but I put in nevertheless ):

            <assembly-descriptor>
            <container-transaction>

            <ejb-name>MessageBean</ejb-name>
            <method-name>*</method-name>

            <trans-attribute>Required</trans-attribute>
            </container-transaction>
            </assembly-descriptor>

            The above changes made the bean get really deployed. Now it can get messages. Using the JMX console, I can see what is going on. I guess I shld get rid of the bean managed transaction part ( I think I saw it in the Jboss 2.4 docs at soruceforge ).

            thanks,
            ms