0 Replies Latest reply on Apr 15, 2009 1:15 PM by tajh

    How to locate MDB MXbean via JNDI?

      I've searched the documentation and the forums, wasn't able to find this particular issue addressed anywhere.

      I have a MDB (called MyMDB) deployed in a JAR, and I have a custom JMX bean deployed in a SAR. I would like to access the org.jboss.ejb.plugins.jms.JMSContainerInvokerMBean corresponding to my MDB so that the custom JMX bean can call the startDelivery() and stopDelivery() methods on the JMSContainerInvokerMBean. So far, I have been unable to locate the JMSContainerInvokerMBean in JNDI from within the SAR.

      I have tried the following JNDI contexts, to no avail:

      java:/comp/env/MyMDB
      java:/com/MyMDB
      java:/MyMDB
      local/MyMDB
      /MyMDB
      MyMDB


      The JNDIView service in the JMX Console reports the following:

      Ejb Module: MyMDB.jar

      java:comp namespace of the MyMDB bean:

      +- HandleDelegate (class: org.jboss.proxy.ejb.handle.HandleDelegateImpl)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)


      And of course I can access the desired JMSContainerInvokerMBean via the JMX console also, at something like the following:

      jboss.j2ee

      * binding=message-driven-bean,jndiName=local/MyMDB@9049759,plugin=invoker,service=EJB


      That number following the @ sign seems to be different every time I start JBoss, and this JNDI name seems to only apply from within the MDB's JAR scope itself. At first, I wasn't sure I could get access to the JMSContainerInvokerMBean from outside the MDB's JAR, but if the JMX Console can do it, I should be able to do it from within my custom JMX bean in my SAR.

      So does anyone know the correct JNDI path to construct to get a handle to this?

      For reference, I am running the following:
      JBoss AS 4.2.2 GA
      JBoss Messaging 1.0
      Java SDK 1.5.0_12

      And this is what my client JNDI lookup code looks like:

      JMSContainerInvokerMBean mbean = null;
      try {
       Context context = new InitialContext();
       mbean = (JMSContainerInvokerMBean)context.lookup(jndiName);
      } catch (NamingException ne) {
       log.error("Unable to retrieve JMSContainerInvokerMBean at JNDI context " + jndiName, ne);
      } catch (ClassCastException ce) {
       log.error("Object at JNDI context " + jndiName + " is not instance of JMSContainerInvokerMBean", ce);
      }


      Any help is appreciated.