Performing a Thread Dump in Linux or Windows

Amanda Jennewein
Amanda Jennewein
  • Updated

Author: Amanda Jennewein

Date: April 20, 2023

Audience: Everyone

Summary

These instructions indicate generating a single thread dump on each platform we support. Because a thread dump is a single snapshot of the application state at a given time, you'll need to take multiple dumps for our Support team to compare against each other; a single thread will be insignificant.

Instructions

Three thread dumps at a five-second interval are taken automatically as part of the support bundle, which you can generate from the Support page of the Admin Console.

You can also print a single thread dump on demand by running this command from the Jama server:

jamacli jamacore-thread-dump 

For example, to append the thread dump to the file "threaddumps.txt":

jamacli jamacore-thread-dump >> threaddumps.txt

Windows

Running as a Windows Service

1a. If installed using Tomcat installer, click All Programs ->Apache Tomcat 7.0->Monitor Tomcat. An icon should appear in the taskbar.

image.png

1b. If not installed using the Tomcat installer, navigate to /bin and run the following command:
% tomcat7.exe //MS//Tomcat7

 % tomcat7.exe //MS//Tomcat7

image.png

The Tomcat monitor icon should appear in the system tray.;

2. Right-click the icon and select Thread Dump. Run this command every 5 seconds, five times.

3. Look for the thread dump in /logs/stdout or /logs/catalina.out.

Running from startup.bat

1. Open "Windows Task Manager"

2. Find the process ID of the Java process.

3. Make sure /bin is in your command path. Otherwise, navigate to /bin

4. Execute the following command to generate a thread dump:

 % jstack -l  >>  threaddump.txt

Run this command every 5 seconds, five times.

If you receive an error running jstack, such as the one below, then you may need to use psexec:

7988: Insufficient memory or insufficient privileges to attach
The -F option can be used when the target process is not responding

1. Download psexec from this website.

2. Unzip the 'PSTools' directory to a suitable place on your server.

3. Open a command prompt as Administrator and navigate to the location of the PSTools folder using the command prompt.  

image.png

4. Open Task Manager > Services, find your Java (Tomcat) service and note the PID number.

image.png

5. At the command prompt, type 'psexec -s [jdk path]\jstack.exe XXXX >> thread_dump_ddmmyy.log' (where XXXX is your PID and dd/mm/yy is the current date to append to the name of the log file) then hit enter.

image.png

Run this command every 5 seconds, five times.

You can also add the full path of your Java 'bin' directory to the server's system path variable. The Java 'bin' directory is usually in 'Program Files\Java\bin\jdk\bin.' If you add this path to the system variable, you must restart the command prompt for the 'jstack' command to work.

Additional Resources

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.