1 Reply Latest reply on Sep 23, 2014 9:03 AM by Deepak Angeswar

    Unable to access Mbean Server via remoting-jmx

    Deepak Angeswar Newbie

      All,

       

      I have a MBean server in one JVM (service details shown below)

       

      INFO  JMX Connector thread started and listening at: service:jmx:rmi:///jndi/rmi://LDN-LRM-PC-189:19999/jmxrmi/camel

       

      I am trying to access the Mbean server from within my app deployed in EAP 6.3.0

      But unable to connect to the MBean Server.

       

      I tried to connect via a standalone app

       

       

       

       

      import java.util.Date;

      import javax.management.MBeanServerConnection;

      import javax.management.ObjectName;

      import javax.management.remote.JMXConnector;

      import javax.management.remote.JMXConnectorFactory;

      import javax.management.remote.JMXServiceURL;

      public class JMXExample {

          public static void main(String[] args) throws Exception {

                 String host = "LDN-LRM-PC-189";

              int port = 19999;  // management-native port

              String urlString =

                  System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port);

              JMXServiceURL serviceURL = new JMXServiceURL(urlString);

              JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null);

              MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();

       

              ObjectName mBeanName = new ObjectName("java.lang:type=Runtime");

              String attributeName = "StartTime";

              Object attrVal = connection.getAttribute(mBeanName, attributeName);

              System.out.println("Value via JMX: " + new Date((Long) attrVal));

             

              //Invoke on the JBoss AS MBean server

              int count = connection.getMBeanCount();

              System.out.println(count);

              jmxConnector.close();

          }

      }

       

       

       

       

      Following exception is thrown

       

      Exception in thread "main" java.lang.RuntimeException: Operation failed with status WAITING

        at org.jboss.remotingjmx.RemotingConnector.internalRemotingConnect(RemotingConnector.java:235)

        at org.jboss.remotingjmx.RemotingConnector.internalConnect(RemotingConnector.java:148)

        at org.jboss.remotingjmx.RemotingConnector.connect(RemotingConnector.java:99)

        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)

        at com.lombardrisk.ejb3.JMXExample.main(JMXExample.java:23)

       

       

       

      I have added jboss-cleint.jar to the classpath.

      Still facing the same issue. Is there any other JVM argument that is needed to connect via remoting-jmx?

       

      This is used to work with Jboss 5 (which used jnp-cleint).

      remoting-jmx does not seem work at all. Can some one point to the right solution for this.

       

       

      regards,

      D

        • 1. Re: Unable to access Mbean Server via remoting-jmx
          Deepak Angeswar Newbie

          Map<String, Object> env = new HashMap<String, Object>();

          env.put(Context.INITIAL_CONTEXT_FACTORY,org.jboss.naming.remote.client.InitialContextFactory.class.getName());

          env.put(Context.PROVIDER_URL, "rmi://"+ "LDN-LRM-PC-189" + ":" + "19999");      

          JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://LDN-LRM-PC-189:19999/jmxrmi/camel");

          JMXConnector connector = JMXConnectorFactory.connect(address, env);

          MBeanServerConnection connection = connector.getMBeanServerConnection();

          int count = connection.getMBeanCount();

          System.out.println(count);

          connector.close();

           

          All,

           

          The above code works fine (to access a MBeanServer).

          This works fine when I run it a as a standalone application.

           

          Following are the mandatory dependencies.

           

           

           

            <dependency>

                 <groupId>org.jboss</groupId>

                 <artifactId>jboss-remote-naming</artifactId>

                 <version>2.0.1.Final</version>

            </dependency>

            <dependency>

                 <groupId>org.jboss.xnio</groupId>

                 <artifactId>xnio-api</artifactId>

                 <version>3.2.0.Final</version>

            </dependency>

            <dependency>

                 <groupId>org.jboss.xnio</groupId>

                 <artifactId>xnio-nio</artifactId>

                 <version>3.2.0.Final</version>

            </dependency>

           

           

          However if I attempt to run this from within a Singleton EJB (deployed as part of a EAR), I am getting an exception (log attached)

          <!-- Exception

          Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [rmi://LDN-LRM-PC-189:19999 (No connection provider for URI scheme "rmi" is installed)]

            at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)

          -->

           

           

          Can some one point out what the root cause is?

          I have added the necessary JAR files (to XXXX.ear\lib)

           

          1. istack-commons-runtime-2.2.1.jar

          2. xnio-api-3.2.0.Final.jar

          3. xnio-nio-3.2.0.Final.jar

           

           

          I have also tried to add the dependencies as modules to MANIFEST.MF file.

          But exception still persists.

           

          regards,

          Deepak.