Unable to use JConsole with Tomcat running as windows service

29,953

Solution 1

There's a nice GUI to edit the options, no need to muck around in the registry.

Open up the C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe (or just double-click on the monitor icon in the task bar). Go to the Java pane, add the following to the list of arguments, and restart Tomcat.

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Then you can connect with JConsole or the newer VisualVM.

Solution 2

Here's the prescribed way for changing jvmoptions & interacting with the service:

http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html

I would try going into your registry at HKLM/Software/Apache Software Foundation/Procrun 2.0//Parameters/Java and editing the "Options" multi-string value directly.

Solution 3

I'm posting it mainly to record this information to myself, I haven't validated it - but this is supposed to work as well:

http://mysqlandsqlserver.blogspot.com/2010/02/jconsolejmap-and-tomcat-as-windows.html

Solution 4

There is still a rather simple way to connect JConsole to Java process started as Windows Service using the local mode which I discovered here.

Basically it says that in order to connect to Java process launched as a Windows Service you need to launch JConsole as a Windows Service (you can do it using windows native api or using any wrapper like yajsw.)

By the way, this will free you from restarting the Java Process which was critical for me.

Solution 5

Add the following near the top of your catalina.bat

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote ^
    -Dcom.sun.management.jmxremote.port=8086 ^
    -Dcom.sun.management.jmxremote.ssl=false ^
    -Dcom.sun.management.jmxremote.authenticate=false

Stop and restart tomcat (obviously)

Run jconsole.exe. If your tomcat is running as service, then run jconsole.exe as administrator.

Select Remote Process and enter localhost:8086

Share:
29,953
user2649601
Author by

user2649601

Independent Full Stack Developer

Updated on July 09, 2022

Comments

  • user2649601
    user2649601 almost 2 years

    I am running tomcat 6.0.18 as a windows service. In the service applet the jvm is configured default, i.e. it is using jvm.dll of the JRE.

    I am trying to monitor this application with JConsole but cannot connect to it locally. I added the parameter -Dcom.sun.management.jmxremote (which works when starting tomcat with the start.bat script). But the jvm does not seem to pick up the parameter.

  • TJR
    TJR over 12 years
    If on 64bit, HKLM\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\<name>\Java
  • Edd
    Edd over 9 years
    With this config I am able to connect to the process as a remote process on localhost:8086 (no need to enter username and password)
  • Harika Mamidi
    Harika Mamidi over 9 years
    I added these parameters in setEnv file in tomcat7 directory, it works like a charm.
  • hshib
    hshib almost 8 years
    This worked for me on 64 bit Windows laptop. Extra point for not requiring any extra software to be installed.
  • Evandro Silva
    Evandro Silva over 7 years
    Just a note: tomcat6.exe configuration panel is now called Tomcat7w.exe