Taking thread dump on Java in a linux machine is getting failed sometimes with following error with jstack:-
1455: Unable to open socket file /proc/1455/root/tmp/.java_pid1455: target process 1455 doesn't respond within 10500ms or HotSpot VM not loaded**strong text**
with jcmd:-
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
We need to check that if Java socket file is present for the process id or not. It creates a file with pid, eg.
If that file is not present then the command to take thread dump fails. So we need to make sure we do not delete that file or we need to restart the java process in order for it to take back the thread dumps.
Reference:- https://confluence.atlassian.com/kb/jvm-is-not-reachable-with-jstat-and-jstack-1031281491.html