Marcus Junius Brutus
Marcus Junius Brutus

Reputation: 27286

trying to view stack of unresponsive JVM : both jvisualvm and jconsole fail to connect

I have a Java program on my local machine that becomes unresponsive after sometime and appears to freeze without making further progress. I guess it blocks somewhere (it is accessing remote resources over both HTTP and JDBC so a blocking situation is likely). I am trying to connect to it to see a view of the main thread's stack so as to understand where the block occurred. Both jvisualvm and jconsole list the JVM in question (among others running in my system) but both fail to connect.

jconsole balks with "connection failed" (even when I try the insecure option).

jvisualvm appears to connect but when I hit the 'sampler' tab to see the stack it complains with the screenshot below:

enter image description here

The thing is I am using the same utilities (jconsole and jvisualvm) to connect to other JVMs in my system which I have invoked without using any of the JMX options mentioned in this answer and I don't have any issues. How can I get the stack of this unresponsive JVM to see where it blocks?

Upvotes: 1

Views: 558

Answers (2)

Arnoud
Arnoud

Reputation: 96

I faced a similar issue today with a JVM that was completely stuck and I was unable to properly attach jconsole/jvisualvm to it. Also kill -3 <PID> was unsuccessful (no Thread dump).

I was able to trigger a coredump of the JVM using kill -11 <PID> and feed that into jstack as follows: jstack /path/to/java /path/to/core.file. From the jstack output I was able to extract some useful stack information.

Upvotes: 4

Aleš
Aleš

Reputation: 9028

You could just collect a thread dump with kill -3 <PID>.

This will show you all the threads and where they are blocked.

Upvotes: 2

Related Questions