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

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

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 @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.