Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I monitor Tomcat with jvisualvm, showing visualgc?

I have double checked the following:

  • I am running jvisualvm on the same box where Tomcat is running.
  • This is Java 6u19.
  • My Tomcat service is running as the same user that I am logged in as.
  • My Tomcat service is using the exact same JVM directory that I am using jvisualvm from.
  • Tomcat has JMX enabled on a specific port, but I don't think this will help me.

With all of this, I do see my Tomcat process in the "Local" list for jvisualvm. It is shown as "<Unknown Application> (pid 5644)". If I double-click on it, then every tab shows "Not supported for this JVM." However, VisualVM is shown in "Local" and all tabs work for it, obviously using the same JVM instance. There is no obvious way to add a JMX connection to the "<Unknown Application>" instance.

I do see the JMX instance of Tomcat in "Local" as "localhost:(my port number)", and this works, but the Visual GC tab shows "Not supported for this JVM," which I assume means that Visual GC does not work via JMX.

What am I doing wrong? I've tried starting jstatd. It made no difference. When I start jstatd, then visualvm sees a "Local" "jstatd" but when I double click on it, it just seems to monitor that jstatd process and not any other Java process.

NOTE: I decided to try running Tomcat not as a service but directly in a CMD window and, viola, now visualvm works perfectly. I thought I would try this when I ran "jps" and got the complaint "process information unavailable" and Googled for that and found someone who said that they got this when they ran any Java app as a service. This helps in a testbed, but does not help figure out how to monitor a production system.

This is Tomcat running as a Windows service under the Tanuki wrapper on Windows Server 2003.

like image 349
Eddie Avatar asked Aug 05 '11 23:08

Eddie


1 Answers

It is clear from your description that Jvmstat is somehow broken. Jvmstat is used by Visual GC, jps and VisualVM. The reason that you see your Tomcat as unrecognized application under the "Local" node, means that VisualVM detected (via jvmstat) that there is running Java application, but it is unable to get any data about it. This can be somehow connected to the fact that you are runing your Tomcat as Windows service. You can try to quit all java applications and delete hsperfdata_{your_user_name} directory, which is located in %TMP% directory and restart Tomcat and VisualVM. If the Tomcat is correctly recognized under "Local" node, Visual GC will work too. If this fails, start Tomcat and run jps with:

jps -J-Djps.debug=true -J-Djps.printStackTrace=true

and post the output. This could show us, why jvmstat cannot read information from Tomcat.

like image 62
Tomas Hurka Avatar answered Sep 28 '22 17:09

Tomas Hurka