Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded

I get AttachNotSupportedException while running jmockit tests on linux (ubuntu 64bit). Java version is 1.7.0_51. This JDK is from Oracle. Tests are run using ant(that probably is not relevant)

See the stack trace.

[junit] 
[junit] java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
[junit]     at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:89)
[junit]     at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
[junit]     at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
[junit]     at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:136)
[junit]     at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:169)
[junit]     at junit.framework.TestResult.<clinit>(TestResult.java:15)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:356)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1165)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:1016)
[junit] Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
[junit]     at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
[junit]     at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:79)
[junit]     ... 8 more
[junit] Exception in thread "main" java.lang.ExceptionInInitializerError
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:356)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1165)
[junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:1016)
[junit] Caused by: java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
[junit]     at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:89)
[junit]     at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
[junit]     at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
[junit]     at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:136)
[junit]     at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:169)
[junit]     at junit.framework.TestResult.<clinit>(TestResult.java:15)
[junit]     ... 3 more
[junit] Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
[junit]     at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
[junit]     at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:79)
[junit]     ... 8 more
[junit] Running chs.caf.cap

It appears to be related to AttachNotSupportedException while running jMockit tests on IBM JRE. This however is on IBM jre.

like image 625
Jayan Avatar asked Aug 22 '14 03:08

Jayan


2 Answers

My answer will be a little bit unrelated, but I had same issue while trying to dump threads using jcmd. I was getting same error message even though I was running jcmd under the root user.

You need to run jcmd <pid> Thread.print under the same user as java process has, otherwise your connections will be dropped. Java doesn't care if you are root or not.

So basically:

sudo -u <java_process_user> jcmd <pid> Thread.print
like image 54
message Avatar answered Nov 15 '22 08:11

message


Work around for now.

Adding '-XX:+StartAttachListener' to jvm argument fixed the issue.

A similar issue is discussed here at https://code.google.com/p/jmockit/issues/detail?id=136 and http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-October/006098.html (which talks about a possible regression in jdk7 build)

like image 44
Jayan Avatar answered Nov 15 '22 08:11

Jayan