Tomcat Windows Service & VisualVM

I have several instances of Tomcat running in various environments – some of the software my clients use are memory hogs and I have been trying to troubleshoot memory use for months. Finally found a clear explanation of how to get VisualVM, which is included in Java JDk 1.6 on, to work with local apps. Thanks to Matt Woodward’s Blog.

If you install Tomcat as a service, even if it’s running under the same user account that you used to launch VisualVM, Tomcat won’t appear by default in the VisualVM process list.

Luckily it’s easy enough to resolve. Simply open the Tomcat Configuration application and add the following in the Java Options box on the Java tab:

After making this change you do have to restart Tomcat.

This will enable JMX in Tomcat and allow VisualVM to connect to it. You can choose any port you like, and note that if you want to use SSL or authentication you would set those options to true. I haven’t personally messed with authentication so I’m not sure what that authenticates against, but know that if you want to have JMX available on a production system that you can secure it this way, or of course through firewall rules.

With JMX enabled in Tomcat you then go into VisualVM, add a new JMX connection, and point it to localhost:8086 (or whatever port you set JMX to run on). That’s it–you’re now monitoring Tomcat!

VisualVM is a great, free tool that you likely already have on your machine, so you really owe it to yourself to check it out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s