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

    Accessing jboss.system:type=Server via rmi jmx

    dave11

      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

        • 1. Re: Accessing jboss.system:type=Server via rmi jmx
          dave11

          I mean only accessing the jboss mbeans via jconsole would be success

          • 2. Re: Accessing jboss.system:type=Server via rmi jmx
            dave11

            If anyone else has this problem, insert the following in run.bat, that helps::

             

            set JAVA_OPTS=%JAVA_OPTS% -Djboss.platform.mbeanserver
            set JAVA_OPTS=%JAVA_OPTS% -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl
            set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
            set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=12345
            set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
            set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
            set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;../lib/*

             

             

            Dave