Monitoring Windows Tomcat Service with Java VisualVM
Local Java Applications that are running as a Windows Service cannot be monitored with Java VisualVM without some extra efforts. I recently tried to monitor a Tomcat service but I could not find it after starting Java VisualVM. The reason why I did not see the Tomcat Service in the application tree was:
By default, when you start VisualVM only Java applications started by the same user are listed in the Applications tree.
So how I make it possible?? My Approach was to connect via adding jmx connection:
Add these details in java option in registry:
NOTE: Check the ip address from cmd.exe. Use IP address only.
- Restart tomcat service.
- Use the System Account to start Java Visual VMWindows Services most likely are started using the Windows System Account. To monitor these services we need to start Java VisualVM with the system account. This can easily be done by using the PsExectool of the Sysinternals Suite. So start a Windows command line with administrator privileges and typeC:\\PSTools>psexec -i -s cmd.exeUse the new command window to start Java Visual VM:
And Java VisualVM opens including the Tomcat process:
At this stage, although tomcat process is detected by visualvm but it says “Not supported for this JVM”. To get the jvm details, we need to add jmx connection as follows:
- Use the ip address mentioned in -Djava.rmi.server.hostname (10.17.72.25) and port used in –sun.management.jmxremote.port (9023)
Now you should be able to see the jvm details;