问题
I need to add a JMXMP listener to an existing Java application without changing any code. The classic RMI based protocol doesn't work in the target environment do to firewall restrictions.
In other words: I would like to access the JMX of the process just by adding the jmx_remote-optional to the classpath and some env properties analog to com.sun.management.jmxremote for the RMI connector.
I couldn't find anything in the various docs out there - I managed to use JMXMP in the target env with Tomcat (adding a LifecycleEventListener that reads the port from the config) and another program where I explicitly started the listener.
回答1:
Take a look at my github project JMXMPAgent. Docs are a little light, but the premise is simple.
- Clone the repo
- Build with mvn clean install
- Install the agent into a running JVM using the PID of the target JVM, the desired JMXMP listening port, binding interface and target MBeanServer default domain as in the following example. It assumes a PID and the default JMX domain.
java -jar target/helios-jmxmp-agent-1.0-SNAPSHOT.jar -install 11121 8334:127.0.0.1:DefaultDomain
来源:https://stackoverflow.com/questions/34850410/add-jmxmp-listener-for-an-existing-java-application