JMX and Tomcat

January 18, 2011

JMX is the Java Management Extensions, and it allows you to peek inside a running JVM and see what is going on.

Java

To enable it for any Java process, set the following on the command line. Please note that this is insecure and shouldn't be used in production.

 -Dcom.sun.management.jmxremote.port=8224 
 -Dcom.sun.management.jmxremote.authenticate=false 
 -Dcom.sun.management.jmxremote.ssl=false

Tomcat

If you have a tomcat process, do the same but in JAVA_OPTS.

JAVA_OPTS=-Dcom.sun.management.jmxremote.port=8224 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

jManage

jManage is a web based JMX client, and installs with its own web server. you just need to run the supplied file and then navigate to localhost:9090 to get to the console. The default user name is admin and the password is 123456. You'll have to give this to start up the console as well as to log in.

Once up and running, you can add programs using the Add Application menu option. Select JSR160 Application (which is the JMX standard interface) and give the application a meaningful name.

For the URL, enter

service:jmx:rmi:///jndi/rmi://localhost:8224/jmxrmi

where the host is the machine where the java process is running and the port is that specified on the java properties earlier when starting the JVM.

Tags: jmx java tomcat