microsoft / java-debug

The debug server implementation for Java. It conforms to the debug protocol of Visual Studio Code (DAP, Debugger Adapter Protocol).
Other
335 stars 154 forks source link

'Can not attach to current VM' - works on 1 machine, not on 2 others #394

Closed abenz1267 closed 2 years ago

abenz1267 commented 2 years ago

Hi,

I'm currently trying to run this in combination with nvim-jdtls. I'm getting the following error on 2 machines while not on another.

java.lang.RuntimeException: java.io.IOException: Can not attach to current VM
        at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:139)
        at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:53)
        at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:208)
        at org.junit.runner.Runner.<clinit>(Runner.java:22)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:83)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:74)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.io.IOException: Can not attach to current VM
        at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:76)
        at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:57)
        at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
        at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
        at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:133)
        ... 22 more

[Process exited 0]

All 3 machines run Arch Linux and the same Java JDK (openjdk-17). I cannot figure out why it doesn't work on 2/3 machines.

Any pointers eventually?

Regards

abenz1267 commented 2 years ago

fixed it by explicitly adding java runtimes to jdtls