4 Replies Latest reply on Jun 10, 2004 5:45 PM by Mike (JBoss) McLean

    ejb-name is acting as jndi name ... driving me insane

    Mike (JBoss) McLean Newbie

      This is really not complicated and I've followed all the instructions, yet this just won't work for me. Trying to get a simple mdb to work:

      MDB:

      * @ejb.bean
       * name = "TestMessageBean"
       * display-name = "TestQueue"
       * description = "TestMessageBean EJB"
       * jndi-name = "jms/TestMessageBean"
       * acknowledge-mode = "Auto-acknowledge"
      
       * transaction-type = "Bean"
       * destination-type = "javax.jms.Queue"
       *
       * @jboss.destination-jndi-name name="queue/MyTestQueue"
       */
      public class TestMessageBean implements MessageDrivenBean, MessageListener {
       .....
      }



      ejb-jar.xml
      <message-driven >
       <ejb-name>TestMessageBean</ejb-name>
       <ejb-class>com.mikem.jms.TestMessageBean</ejb-class>
       <transaction-type>Bean</transaction-type>
       <message-selector></message-selector>
       <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
      </message-driven>


      jboss.xml
      <message-driven>
       <ejb-name>TestMessageBean</ejb-name>
       <destination-jndi-name>queue/MyTestQueue</destination-jndi-name>
       <configuration-name>Standard Message Driven Bean</configuration-name>
      </message-driven>


      When I start my server I keep getting the same error:
      21:43:14,067 WARN [JMSContainerInvoker] destination not found: queue/TestMessageBean reason: javax.naming.NameNotFoundException: TestMessageBean not bound
      21:43:14,067 WARN [JMSContainerInvoker] creating a new temporary destination: queue/TestMessageBean
      21:43:14,077 INFO [TestMessageBean] Creating
      21:43:14,077 INFO [TestMessageBean] Created
      21:43:14,077 INFO [TestMessageBean] Starting
      21:43:14,077 INFO [TestMessageBean] Bound to JNDI name: queue/TestMessageBean
      21:43:14,077 INFO [TestMessageBean] Started


      My queue/MyTestQueue gets started up properly:
      21:43:10,808 INFO [MyTestQueue] Starting
      21:43:10,818 INFO [MyTestQueue] Bound to JNDI name: queue/MyTestQueue
      21:43:10,818 INFO [MyTestQueue] Started


      And I can write to the queue/MyTestQueue properly.

      Here's the kicker. My MDB is listening on a queue called queue/TestMessageBean. Where is that getting that from? From the ejb-name attribute in the ejb-jar.xml file. If i change that attribute to MikesBean, when the server starts up I'll get the same error, but this time it will say MikesBean not bound. The only way I can get the MDB to be bound to the proper queue is by chaging the ejb-jar.xml file to look like:

      <message-driven >
       <ejb-name>MyTestQueue</ejb-name>
       <ejb-class>com.mikem.jms.TestMessageBean</ejb-class>
       <transaction-type>Bean</transaction-type>
       <message-selector></message-selector>
       <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
      </message-driven>


      Is this normal behaviour?


        • 1. Re: ejb-name is acting as jndi name ... driving me insane
          Tom Vekemans Newbie

          I have set up several apps using MDBs without any problem and when I compare my settings to yours (XML files) I don't see any abnormalities in your settings.

          One noticeable difference is that I don't provide a JNDI name for my MDBs: I never address them directly so there is no need for me to do that. In fact, that's the point of using MDBs in the first place.

          If you really need it I would suggest to use ejb/MyTestbean instead of jms/MyTestBean

          • 2. Re: ejb-name is acting as jndi name ... driving me insane
            Tom Vekemans Newbie

            Hmm seems I was a little bit too quick there...your JNDI name doesn't show up in your XML so that would not be it.

            What strikes me is that in your jboss.xml the configuration-name element is placed after the destination-jndi-name element, whereas in all the examples I have ever seen the order of those 2 is just the opposite. I don't have the DTD at hand so I cannot confirm that the order is actually important, but you could try to switch them.

            Another thing in that respect is I would start the destination name with a lowercase (so that would be queue/myTestQueue)

            Just guessing of course, but then again what to do if everything appears to be correct ? ;-)

            • 3. Re: ejb-name is acting as jndi name ... driving me insane
              Mike (JBoss) McLean Newbie

              Thanks for the input. I've tried changing the order of the 2 attributes in the jboss.xml, but to no avail.

              I've tried all the examples I could find by copy-pasting all the code and the problem remains.

              The MDB is trying to bind itself to a queue named by whatever is found in the <ejb-name> node of the <message-driven> definition. No matter what I do, it completely ignores the <destination-jndi-name>queue/MyTestQueue</destination-jndi-name>
              in the jboss.xml file and creates it's own queue based on the name in the <ejb-name> element, and it binds itself to that.



              in other words, if I have
              <ejb-name>Mike</ejb-name>

              The error message I get is:
              21:43:14,067 WARN [JMSContainerInvoker] destination not found: queue/Mike reason: javax.naming.NameNotFoundException: Mike not bound
              21:43:14,067 WARN [JMSContainerInvoker] creating a new temporary destination: queue/Mike
              21:43:14,077 INFO [TestMessageBean] Creating
              21:43:14,077 INFO [TestMessageBean] Created
              21:43:14,077 INFO [TestMessageBean] Starting
              21:43:14,077 INFO [TestMessageBean] Bound to JNDI name: queue/Mike
              21:43:14,077 INFO [TestMessageBean] Started

              If the <ejb-name>'s value is MikesQueue, the error when starting up is:
              21:43:14,067 WARN [JMSContainerInvoker] destination not found: queue/MikesQueue reason: javax.naming.NameNotFoundException: MikesQueue not bound
              21:43:14,067 WARN [JMSContainerInvoker] creating a new temporary destination: queue/MikesQueue
              21:43:14,077 INFO [TestMessageBean] Creating
              21:43:14,077 INFO [TestMessageBean] Created
              21:43:14,077 INFO [TestMessageBean] Starting
              21:43:14,077 INFO [TestMessageBean] Bound to JNDI name: queue/MikesQueue
              21:43:14,077 INFO [TestMessageBean] Started

              • 4. Re: ejb-name is acting as jndi name ... driving me insane
                Mike (JBoss) McLean Newbie

                Found it!

                Turns out the code and configuration were fine. It was the way in which x-doclet (or MyEclipse Enterprise Workbench) setup the files in my project. It put jboss.xml outside the META-INF directory (same level), so the container couldn't find it. I put the file inside META-INF and I'm a happy camper.

                I'm a newb at the whole EJB thing, so I rely on my tools a bit too much.