Documenting Problems That Were Difficult To Find The Answer To

Jstack Unable to Contact Target Process

In Java one of the most useful tools for diagnosing thread-related issues is jstack. It outputs a stack trace of every thread of a running process – and can also give an indication of the state of locks.

However I was getting the following error message when trying to attach jstack to a running process:

17840: 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

The solution, amazingly, was to run the jstack command as the same user as the running Java process.

The command to use for this is:

sudo -u <user> jstack -l <pid>

e.g. if the Java process is running as user “oracle” with process ID 45132 then you would execute:

sudo -u oracle jstack -l 45132

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: