2 Replies Latest reply on Oct 25, 2016 2:31 AM by cfrantsen

    jboss.as:management-root=server not found using queryNames()

    cfrantsen Newbie

      I am using queryNames() to try and find the jboss.as:management-root=server mBean but nothing is returned, all other methods I have tried finds the mBean. WildFly 10.0 was used during my tests. See below for some test code that shows the problem. Any ideas as to why this happens?

       

      import java.util.Set;
      import java.util.Objects;
      import javax.management.MBeanServerConnection;
      import javax.management.remote.JMXConnector;
      import javax.management.remote.JMXConnectorFactory;
      import javax.management.remote.JMXServiceURL;
      import javax.management.*;
      
      
      public class test {
          public static void main(String[] args) throws Exception {
              JMXServiceURL address = new JMXServiceURL("service:jmx:remote+http://localhost:9990");
              JMXConnector connector = JMXConnectorFactory.connect(address, null);
              MBeanServerConnection connection = connector.getMBeanServerConnection();
      
              ObjectName bean = new ObjectName("jboss.as:management-root=server");
      
              System.out.println("getMBeanInfo()");
              System.out.println(connection.getMBeanInfo(bean).getAttributes());
      
              System.out.println("queryNames(ObjectName, null)");
              System.out.println(connection.queryNames(bean, null));
      
              System.out.println("queryMBeans(ObjectName, null)");
              System.out.println(connection.queryMBeans(bean, null));
      
              System.out.println("queryNames(null, null)");
              Set<ObjectName> o = connection.queryNames(null, null);
              for (ObjectName name : o) {
                  if (Objects.equals(name.toString(), bean.toString())) {
                      System.out.println(name);
                  }
              }
          }
      }
      

       

       

      Test run

      $ java -cp .:/opt/wildfly/bin/client/jboss-client.jar test
      Oct 22, 2016 6:55:14 PM org.xnio.Xnio <clinit>
      INFO: XNIO version 3.3.4.Final
      Oct 22, 2016 6:55:14 PM org.xnio.nio.NioXnio <clinit>
      INFO: XNIO NIO Implementation Version 3.3.4.Final
      Oct 22, 2016 6:55:14 PM org.jboss.remoting3.EndpointImpl <clinit>
      INFO: JBoss Remoting version 4.0.18.Final
      getMBeanInfo()
      [Ljavax.management.MBeanAttributeInfo;@42d80b78
      queryNames(ObjectName, null)
      []
      queryMBeans(ObjectName, null)
      [org.jboss.as.controller.ModelController[jboss.as:management-root=server]]
      queryNames(null, null)
      jboss.as:management-root=server