1 Reply Latest reply on Jul 26, 2002 1:04 AM by Brian Dueck

    RemoteMBeanServer.isRegistered() always returns false

    Brian Dueck Newbie


      I am trying to use RemoteMBeanServer to discover information about the MBean that exist inside JBoss 3.0.1RC1. Specifically, I want to be able to use methods like isRegistered() and getMBeanInfo() to be able to introspect on the MBeans using standard JMX mechanisms.

      I can connect to JBoss and get a reference to a RemoteMBeanServer with ease. However, whenever I try to use isRegisterered() or getMBeanInfo() on what should be a valid MBean, the MBeanServer acts like the MBean doesn't exist.

      Here's some sample code (based closely on an earlier post in this forum) for connecting to JBoss and for using those methods on a standard JBoss MBean. Pretty well you can change the ObjectName to any MBean inside JBoss and you get the same result - RemoteMBeanServer doesn't think they are registered. The html JMX browser shows that these objects do exist.

      Any ideas?



      import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
      import org.jboss.jmx.connector.RemoteMBeanServer;
      import org.jboss.jmx.connector.rmi.RMIConnectorImpl;

      import javax.naming.InitialContext;
      import javax.management.ObjectName;
      import java.io.File;
      import java.net.InetAddress;

      public class test {
      public static final String DEPLOYER_NAME = "jboss.system:service=MainDeployer";

      public static void main(String args[] ) {
      InitialContext ctx = null;
      try {

      // get a remote mbean server from the jndi
      java.util.Properties props = new java.util.Properties();
      props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, org.jnp.interfaces.NamingContextFactory.class.getName());
      props.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      ctx = new InitialContext(props);

      String serverName = InetAddress.getLocalHost().getHostName();
      String adaptorName = "jmx:" + serverName + ":rmi";

      RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup(adaptorName);
      RemoteMBeanServer server = new RMIConnectorImpl(adaptor);

      ObjectName objectName = new ObjectName(DEPLOYER_NAME);

      // lots of MBeans - my stock 3.0RC1 returns 111 mbeans

      // ...but isRegistered() always returns false...

      javax.management.MBeanInfo info = server.getMBeanInfo(objectName);

      // ...and info is alway null

      catch (Exception e) {
      finally {
      try {
      if (ctx != null) ctx.close();
      catch (Exception ignore) {}