5 Replies Latest reply on Feb 28, 2012 8:56 AM by EJP

    MBeanServer location in JNDI tree

    luismi fernandez

      I'm testing methods that use a MBeanServer from JConsole and MBean browser in EM console. I launch the JConsole using this parameters:

      jconsole -J-Djava.class.path=/home/user/wlfullclient- -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote

      When I use the JConsole for testing I obtain the MBeanServer in this way:

      InitialContext ctx = new InitialContext();
      server = (MBeanServer)ctx.lookup("java:comp/jmx/runtime");

      And when I use the MBean browser I have to to use this code:
      server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");

      I'm following the next Oracle documentation, but I want to know if there is other way to use only once String to found the MBeanServer in the JNDI tree.

      Does anybody know a different way to do this?

      Thanks in advance,

      Make Local Connections to the Runtime MBean Server+

      Local clients can access a WebLogic Server instance’s Runtime MBean Server through the JNDI tree instead of constructing a JMXServiceURL object. Only the Runtime MBean Server registers itself in the JNDI tree.+

      When accessed from JNDI, the Runtime MBean Server returns its javax.management.MBeanServer interface. This interface contains all of the methods in the MBeanServerConnection interface plus additional methods such as registerMBean(), which local process can use to register custom MBeans. (See MBeanServer in the J2SE 5.0 API Specification.)+

      If the classes for the JMX client are located at the top level of an enterprise application (that is, if they are deployed from the application’s APP-INF directory), then the JNDI name for the Runtime MBean Server is:+


      If the classes for the JMX client are located in a Java EE module, such as an EJB or Web application, then the JNDI name for the Runtime MBeanServer is:+


      For example:

      InitialContext ctx = new InitialContext();

      server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");