2 Replies Latest reply on Jul 26, 2013 5:18 AM by dave11

    Accessing jboss.system:type=Server via rmi jmx

    dave11 Newbie

      Hi all,

      I'm trying to access jboss server (jboss-5.1.0.GA) mbeans from java like this:

           public void initConnection() throws IOException, MalformedURLException {
                String serverURL = "service:jmx:rmi:///jndi/rmi://"
                          + adminServer.getHost() + ":" + adminServer.getPort() + "/jmxrmi";
                HashMap env = new HashMap();
                if (adminServer.getUsername() != null
                          && adminServer.getPassword() != null) {
                     String[] creds = new String[2];
                     creds[0] = adminServer.getUsername();
                     creds[1] = adminServer.getPassword();
                     env.put(JMXConnector.CREDENTIALS, creds);
                }
                JMXServiceURL url = new JMXServiceURL(serverURL);
                connector = JMXConnectorFactory.connect(url, env);
                connection = connector.getMBeanServerConnection();
           }
      

       

      When I then get the ObjectName, I can get the java.lang:type=Runtime, but I cannot acces the jboss.system:type=Server

       

       
      
                try {
                     service = new ObjectName("java.lang:type=Runtime");
      //                service = new ObjectName("jboss.system:service=MainDeployer");
      //                service = new ObjectName("jboss.system:type=Server");
                } catch (MalformedObjectNameException e) {
                     throw new AssertionError(e.getMessage());
                }
      

       

      as I'm getting:

       

      javax.management.InstanceNotFoundException: jboss.system:type=Server 
      

       

      I would like to be able to get the same information as you do via http://localhost:8080/web-console/

       

      Does anyone know how to get this working?

       

      Thank you