I'll reuse an answer I wrote up earlier for this question:cannot connect to Tomcat's Mbeanserver via Jconsole in Java6 It ' s not complete, but might help: Suppose you has the JMX Server (alias ' jmx Agent ' alias ' The JVM you want to connect to ') running on ' TARGET machine ' wit H the RMI registry Port at ' RMI Registry Port ' and the jmx RMI Server port at ' jmx RMI Server Port '. Note:
- The RMI registry tells JMX clients where to find the jmx RMI server Port; Information can obtained under key
jmxrmi .
- The RMI registry port is generally known as it was set through system properties at the JVM startup.
- The JMX RMI server port is generally not known as the JVM chooses it in random (if no other precautions is taken).
The following URI would leads to successful connection (tested) service:jmx:rmi://<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
This looks nasty. Let ' s cut it apart. This URI is a RFC2609 "Service location Protocol URL" (well, it's really a URI, right?) It is composed of:
service-A constant
jmx:rmi-The service type composed of: abstract type jmx and URL schemermi
- The Rest-the SAP (Service Access Protocol specification)
SAP is decomposed into:
//<TARGET_MACHINE>:<JMX_RMI_SERVER_PORT>-Ipsite
/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi-URL part
A well-informed JMX client connects to the ' Ipsite ' to do jmx-over-rmi exchanges; But what is the JMX client that doesn ' t KNOW that port? Patience ... URL part was decomposed into:
/jndi/-This seems to tell the JMX client, it can get lookup information at the location that follows
rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi-YEP, we get information about the JMX RMI Server at the RMI registry, under the lookup keyjmxrmi
This is somewhat cart-before-horse, as one have to contact the RMI registry given by the latter part of T He SLP URL first. After scratching head, intuitively, let's try: service:jmx:rmi://<TARGET_MACHINE>/jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Yes, that's works! The JMX RMI server port is nicely obtained from the registry. On second thoughts, the target machine should also is obtained from the registry, thus: service:jmx:rmi:///jndi/rmi://<TARGET_MACHINE>:<RMI_REGISTRY_PORT>/jmxrmi
Even better, that works, too! References:
- Http://download.oracle.com/javase/6/docs/api/javax/management/remote/rmi/package-summary.html
- Http://download.oracle.com/javase/6/docs/api/javax/management/remote/JMXServiceURL.html
- Http://mx4j.sourceforge.net/docs/ch03s04.html
- Http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdevg
- Http://www.rfc-editor.org/rfc/rfc2609.txt
|