1 Reply Latest reply: Aug 4, 2010 2:30 PM by 843798 RSS

    Access remotely to JMX server

    843798
      Hi,

      I'm a newbie in JMX (as well as in Java in general).. hope you can help me.
      I'm trying to write a JMX server that manage a simple MBean and access it remotely from a JMX client.
      Here is my JMX server code:
      /**
      * Create MBean server
      */
      public void createMBeanServer() {
      _mbs = MBeanServerFactory.createMBeanServer();
      }

      /**
      * Register the server MBeans.
      */
      private void registerServerMBeans() {
      MBeanNameA = new ObjectName("TEST:type=InternalA");
      InternalA mbeanA = new InternalA();
      _mbs.registerMBean(mbeanA, MBeanNameA);
      }


      /**
      * Start RMI connector
      */
      private void startRMIConnector(){

      LocateRegistry.createRegistry(8889);
      HashMap<String, Object> env = new HashMap<String,Object>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
      env.put(Context.PROVIDER_URL, "rmi://localhost:8889");
      url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8889/server");
      cs.start();
      }

      The first question is: How can I make this JMX server remotely reachable?
      The second question is how to write the client's side code in order to connect to the JMX server?

      Any help is appreciated.

      Thanks is advanced!

        • 1. Re: Access remotely to JMX server
          843798
          Hi hadardar

          welcome to JMX! :)

          There is plenty of documentation(unfortunately some obsolete) around the net to accomplish what you are asking for. I strongly recommend you to start from the official JMX page from the Java documentation page. Read the overview and the tutorial page

          [http://download.oracle.com/javase/6/docs/technotes/guides/jmx/index.html]

          Further at the examples section:
          [http://download.oracle.com/javase/6/docs/technotes/guides/jmx/examples.html]

          you will find plenty of examples(downloadable also) of using the RMI connectors to allow remote access to the MBeanServer

          Further, because as you said you are a beginner in Java, keep an eye of the The Java Tutorial Page for JMX (They also provide specialized trails for different aspects of the Java Programming Language)

          [http://download.oracle.com/javase/tutorial/index.html]

          Hope that helps,

          Regards,
          Christos

          Edited by: cvasilak@java on Aug 4, 2010 10:29 PM