Com.sun.tools.attach.AttachNotSupportedException: Cannot open socket file: Target process is not responding or HotSpot VM is not loaded

I get an AttachNotSupportedException while running jmockit tests on linux (ubuntu 64bit). The Java version is 1.7.0_51. This JDK is from Oracle. Tests are done using ant (which probably doesn't matter)

See 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 

This seems to be due to an AttachNotSupportedException when running jMockit tests in the IBM JRE . This is, however, on an IBM jre.

+9
source share
3 answers

Work now.

Adding the argument '-XX:+StartAttachListener' to jvm fixes the problem.

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 the jdk7 assembly)

+17
source

My answer will be a bit unrelated, but I had the same problem when trying to jcmd streams using jcmd . I was getting the same error message, although I was running jcmd as root .

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

So basically:

 sudo -u <java_process_user> jcmd <pid> Thread.dump 
+6
source

Like @bbarker, I got the same error, but on JDK 1.8.0_161, using the Linux subsystem in Windows 10 ("Bash on Ubuntu on Windows"). Setting up the Surefire plugin with the JVM argument mentioned above fixed the problem for me too:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.21.0</version> <configuration> <argLine>-XX:+StartAttachListener</argLine> </configuration> </plugin> 

Running tests from the β€œnormal” Windows command line works without the above.

+1
source

Source: https://habr.com/ru/post/1200900/


All Articles