<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d11356004\x26blogName\x3dxception\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://openrent.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://openrent.blogspot.com/\x26vt\x3d-4655156434419967503', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe", messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER, messageHandlers: { 'blogger-ping': function() {} } }); } }); </script>

Jconsole and Tomcat 5

The latest version of Sun's JDK (5.0) includes a fantastic utility called Jconsole. This program makes use of JMX (Java Management Extensions) to let you keep tabs on your JVM's. When you pair this tool with the Tomcat servlet container, you get to peek inside what was previously a black box. You can watch (in real time or historically) exactly what the JVM that runs Tomcat is doing. And you can do it remotely from your workstation.

The only prerequisite is to have the latest JDK (1.5.0_08 as of this writing) installed on both the server and workstation. After you ensure Java is installed, here's how you set it up:

1) Open the /tomcat/bin/catalina.sh file and add the following directive:
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

These directives will enable JMX when the Tomcat JVM is started. It tells the daemon to listen on port 8004 and to not use SSL or authentication. (NOTE: if this server is connected to open Internet, it is best to enable SSL and authentication)

2) Start Tomcat normally. You should now see port 8004 listening for JMX connections:

# netstat -pantl|grep LISTEN | grep 8004
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8004 0.0.0.0:* LISTEN 2544/java

3) From a remote Windows workstation, invoke jconsole:
Start/Run/cmd then type: C:\Documents and Settings\Jeffrey Costa>"c:\Program Files\Java\jdk1.5.0_08\bin\jconsole.exe

4) Once the agent connection dialog box comes up, choose the "Remote" tab, and enter the IP address of the remote machine and 8004 in the "Port" field. A username and password are not necessary here.


5) Jconsole will now begin showing you information about the Tomcat JVM: