Skip to content

How to get jstack and jmap to work with Tomcat 7 installed as a service on Windows Server 2008 R2

Today I had an application server running on Tomcat 7 installed as a service, and I wanted to inspect memory and stack.

The problem is that the service, like most services, was running as ‘Local System’ and the java tools can only see processes from the same user.

The situation is further complicated thru Windows Server 2008 R2 no longer allowing any kind of interaction on part of the Local System account.

There are many pages on the internet outlining solutions, but what worked for me was this:

  1. If you’re remote desktopping, be sure to start remote desktop with the command
    mstsc /admin
  2. Install PsTools and make sure psexec is on your path
  3. Open up Task Manager, and find the PID (process id) of the tomcat (or any other java app that is running as a service)
  4. execute
    psexec -s {full path to jdk bin}jstack {PID} >> jstack.log
    psexec -s {full path to jdk bin}jjmap -dump:format=b,file=jmap.dump {PID} 
  5. Inspect jstack.log and jmap.dump



Get every new post delivered to your Inbox.