Tomcat as Windows Service

The following steps describe how to profile a running Tomcat/Java process where Tomcat has been setup as a Windows service; using Java Flight Recorder and Mission Control (requires JDK 7 or newer).

Preparation

  • Open Tomcat’s Windows Service configuration helper: $TOMCAT_HOME\bin\Tomcat8w.exe
  • Switch to the Java tab

Tomcat8w

  • Append the following lines in order to enable flight recorder:
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
  • Ensure the following lines are present as well in order to be able to connect over Mission Control. Adjust the same as needed:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.host=localhost
-Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
  • Click OK and restart Tomcat

Profiling

  • Start Mission Control: $JAVA_HOME\bin\jmc.exe
  • Click File > Connect
  • Create a new connection

JMC New Connection

  • Adjust the connection settings so they match the Tomcat JMX parameters

JMC New Connection Settings

  • Start flight recording (again, adjust the settings as needed and proceed)

JMC New Connection Start FC