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

后端 未结 4 1251
野的像风
野的像风 2020-12-08 22:42

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

相关标签:
4条回答
  • 2020-12-08 23:14

    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.dump 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.dump
    
    0 讨论(0)
  • 2020-12-08 23:24

    I also got a similar problem when tried to check for Thread Deadlock. You can also use the command jcmd <PID> Thread.print to print the thread dump on the console and check if the program has a deadlock. You can check my answer with steps on Deadlock detection in Java

    0 讨论(0)
  • 2020-12-08 23:32

    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)

    0 讨论(0)
  • 2020-12-08 23:32

    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"). Configuring the Surefire plugin with the JVM argument mentioned above fixed the issue for me as well:

        <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 the tests from a "normal" Windows command prompt works without the above, though.

    0 讨论(0)
提交回复
热议问题