Sometimes while using a tools like jmap,jstack on a running java process, we are not able to connect to the java process and below error is observed.
Error Message |
Solution :
Scenario 1)
If the service is running as a specific user, you need connect by logging into the same session and then try to run jmap or jstack etc.
Scenario 2)
If you are using Remote Desktop, you need to connect using "mstsc /admin" (used to be /console) and try to run jmap or jstack again
Scenario 3)
Target Java process is running as System Process (in case of Windows)
In case if the target java process is running as System Process, we need to use PsExec utility.
Steps to use PsExec utility :
1) Download the PsTools from here.
2) Unzip the PsTools and copy the PsExec.exe
3) Execute the original command using PsExec utility with -s
Syntax :
PsExec -s {original_command}
Example :
PsExec -s jmap -dump:format=b,file=c:/heapdump.bin 4708
Example - Executing jmap using psexec. |
Scenario 3 worked perfectly for me. Thanks!
ReplyDelete