Does Java 6 open a default port for JMX remote connections?

前端 未结 7 1093
终归单人心
终归单人心 2020-12-07 09:46

My specific question has to do with JMX as used in JDK 1.6: if I am running a Java process using JRE 1.6 with

com.sun.management.jmxremote

7条回答
  •  难免孤独
    2020-12-07 10:27

    I've been working recently to figure out how to enable remote JMX management from java code, without requiring the JVM to have been started with special properties set. The solution I settled on is to start my own private RMI registry -- easy enough -- and to expose the JMX service on that registry. I create my own MBeanServer, then create a new JMXConnectorServer. The JMXConnectorServer is created through a call like

    connector = JXMConnectorServerFactory.newJMXConnectorServer(url, null, server);
    

    Where server is the MBeanServer, and url is an instance of JMXServiceURL.

    The url is of the form "service:jmx:rmi:///jndi/rmi://localhost:/jmxrmi" where port is the (local) private registry's port number. "jmxrmi" is the standard service name for the JMX service.

    After setting this up, and starting the connector, I find that I can connect to it from jconsole using hostname:port.

    This entirely addresses my needs; I will be interested to know if anyone sees a flaw in this approach.

    Reference: JMX Tutorial, Chap. 3

提交回复
热议问题