linux – com.sun.tools.attach.AttachNotSupportedException:无法打开套接字文件:目标进程未响应或未加载HotSpot VM

我在 linux(ubuntu 64bit)上运行jmockit测试时得到AttachNotSupportedException. Java版本是1.7.0_51.这个JDK来自Oracle.使用ant运行测试(可能不相关)

查看堆栈跟踪.

[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

它似乎与AttachNotSupportedException while running jMockit tests on IBM JRE有关.但这是在IBM jre上.

解决方法

现在就来解决.

将’-XX:StartAttachListener’添加到jvm参数修复了该问题.

这里讨论类似的问题,分别在https://code.google.com/p/jmockit/issues/detail?id=136http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-October/006098.html(讨论jdk7构建中可能的回归)

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...