Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jstack: Target process not responding

I am running Ubuntu server edition and I wanted to take a thread dump of Tomcat.

So, I first tried to find out which PID tomcat uses:

$ jps -l 5809 sun.tools.jps.Jps 

But it's not there?

So, I used top instead and found out the PID 5730.

Then I called jstack to get the thread dump:

$ sudo jstack -l 5730 5730: Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding 

What's going on? :-(

I already tried to export CATALINA_TMPDIR as described in Jstack and Jstat stopped working with upgrade to JDK6u23 but that didn't change anything:

$ export CATALINA_TMPDIR=/tmp $ sudo /etc/init.d/tomcat6 restart  * Stopping Tomcat servlet engine tomcat6    ...done.  * Starting Tomcat servlet engine tomcat6    ...done. $ sudo jstack -l 5934 // new PID after restart 5934: Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding 

Update:

I also tried sudo -u tomcat6 jstack -l -F 5730 > threaddumpexceptions2.txt but it only gives me tons of exceptions on the console.

like image 709
Timo Ernst Avatar asked Sep 14 '11 17:09

Timo Ernst


People also ask

What is Jstack command?

Description. The jstack command prints Java stack traces of Java threads for a specified Java process. For each Java frame, the full class name, method name, byte code index (BCI), and line number, when available, are printed.

How do I get Jstack on Linux?

TO GET THE JSTACK: Enter the following commands in the order shown, replacing: <installDir> with the path to the directory that Analyze is installed under. <processId> with the PID you got from the above. <someFileName> with the name of a file which the output of the jstack command will be written to.

How do you take a thread dump?

Ctrl + Break (Windows) In Windows operating systems, we can capture a thread dump using the CTRL and Break key combination. To take a thread dump, navigate to the console used to launch the Java application, and press the CTRL and Break keys together.


2 Answers

I think you need to run jstack as the same user that runs the Tomcat process. Note also that jps only returns processes for the current user. You would get the pid for the Tomcat process by running jps with sudo or as the Tomcat process user.

This bug report may also be useful: https://bugs.launchpad.net/ubuntu/+source/sun-java6/+bug/597098

like image 33
Michael Pigg Avatar answered Oct 02 '22 20:10

Michael Pigg


I got it working by doing two things:

  1. Changed call to: sudo -u tomcat6 jstack -J-d64 -m pid
  2. Replaced OpenJDK with Sun's original sun-6-jdk and sun-6-jre packages

Explanation for part 1: I switched to 64-bit mode, used sudo and run the command as Tomcat user.

Note: Part 2 might not be necessary. For some users it seems like part 1 is enough. In fact, try to add just the sudo command first. It might already do the trick.

like image 114
Timo Ernst Avatar answered Oct 02 '22 19:10

Timo Ernst