简体   繁体   中英

Why is jstack unable to open socket file when trying to generate a thread dump?

I am trying to generate a thread dump of a java process being run on a Linux instance in AWS. I am using the jstack command on OpenJDK version 1.8.0. The current command I am running is sudo -u <user> jstack -l <java pid> where <user> is the user that started the JVM.

When I run this, I receive the error Unable to open socket file: target process not responding or HotSpot VM not loaded

Potential Problem:

While reading about how jstack works, I noticed that jstack is supposed to generate a socket file /tmp/.java_pidXXX in order to attach to the process. This file is not generated.

My potential solution is that if I can get the socket file to generate, hopefully jstack will be able to run properly.

I am unsure why this error is occurring, but my only idea is that this could this be some kind of permissions error to create files in the /tmp directory. I tried testing my permissions by creating text files in the /tmp directory and I was able to create text files.

How can I get this socket file to generate? Any potential solutions would be greatly appreciated.

Edit

Here I have added the command that was used to create the JVM. The command used to get this command was ps -aux | grep java ps -aux | grep java

java -server -Xmx8192m -XX:+HeapDumpOnOutOfMemoryError ->XX:HeapDumpPath="/tmp" -XX:MaxPermSize=256M -Djava.awt.headless=true ->Dsling.run.modes=dynamicmedia_scene7,, <instance_name>,samplecontent,crx3,crx3ta>r -Djava.locale.providers=CLDR,JRE,SPI -jar crx-quickstart/app/cq-?>quickstart-6.5.0-standalone-quickstart.jar start -c crx-quickstart -i >launchpad -p 4502 -Dsling.properties=conf/sling.properties

Solution:

An update for anyone who comes across this in the future. I found a solution that worked for me by changing the command that I was using to initially start the JVM. I added the flag -XX:+StartAttachListener which forces the process to generate the /tmp/.java_pidXXX socket file during the booting of the JVM.

Other tips I came across in my journey to finding this solution:

Make sure the user executing the jstack command is the same user that who ran the process that you are trying to take the thread dump of.

Also, make sure the socket file /tmp/.java_pidXXX is not being automatically cleaned up by any background cleanup processes in the /tmp directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM