I’ve been trying to get to the bottom of a “Java Heap Space” error on my local Railo installation and decided to use?JConsole?to monitor Tomcat server. ?JConsole?is a very useful Java application monitoring tool, which is bundled into every JRE. ?You can run it by simply executing jconsole binary:
$JAVA_HOME/bin/jconsole
Where $JAVA_HOME is the path to your Java installation.
By default, JConsole picks up all local Java processes, which you can monitor individually. ?Unfortunately, Tomcat doesn?t seem to be listed under local processes and I had to use remote connection instead. ?The way to connect to Tomcat with JConsole is a little tricky and this is what you need to do:
You need to tell Tomcat to accept clients on TCP port 8999, on the host ?localhost?, without authentication.
[infobox type=”warning” align=”center” width=”75%”]DO NOT disable remote authentication in production environment. It should only be done for testing purposes in development/staging environments.[/infobox]
To translate this into code, set CATALINA_HOME environment variable to this:
$CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=localhost";
$ export CATALINA_OPTS;
(Re)start Tomcat and you should now be able to monitor it on localhost:8999
Here are some JConsole screen shots:
References:
Monitoring Tomcat with JMX
Using JConsole to Monitor Applications