1

I have a simple Java test case in VS Code that runs fine, but when I try to step through it in debug it shows the error "Failed to launch debuggee VM. Reason: VM exited with status1"?

I have these extensions installed

  • Debugger for Java
  • Extension Pack for Java Language Support for Java(TM) by Red Hat
  • Maven for Java
  • Project Manager for Java
  • Test Runner for Java
  • Remote - SSH
  • Remote - SSH: Editing Configuration
  • Files Remote Explorer
import org.junit.Assert; 
import org.junit.Test;

public class ProgNodeTest {

    @Test
    public void progNodeShouldBeInitialized() {
        ProgNode pn = new ProgNode();
    }
}

The TEST RESULTS window shows

The test run did not record any output.

The DEBUG CONSOLE window shows

ERROR: JDWP unable to get necessary JVMTI capabilities.

I found a VS Code log file that might give a hint to the issue.

C:\Users<user>\AppData\Roaming\Code\logs\20230417T084536\window1\exthost\output_logging_20230417T084539

[Error - 8:49:00 AM] Apr 17, 2023, 8:49:00 AM [error response][launch]: Failed to launch debuggee VM. Reason: VM exited with status 1
Failed to launch debuggee VM. Reason: VM exited with status 1
com.microsoft.java.debug.core.DebugException: Failed to launch debuggee VM. Reason: VM exited with status 1
    at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.launch(LaunchRequestHandler.java:326)
    at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handleLaunchCommand(LaunchRequestHandler.java:193)
    at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handle(LaunchRequestHandler.java:95)
    at com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:93)
    at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
    at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:92)
    at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:118)
    at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.lambda$new$0(AbstractProtocolServer.java:81)
    at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
    at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
    at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
    at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
    at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

And the 3-Language Support for Java (Syntax Server).log file shows what might be the cause of the error. This message is not on its project's build path sounds important.

[Error - 8:45:49 AM] Apr 17, 2023, 8:45:49 AM Problem with folding range for /dtxsql-java_92d3a23d/_/traceprofiler/src/test/java/com/xx/xx/traceprofiler/ProgNodeTest.java
_/traceprofiler/src/test/java/com/xx/xx/traceprofiler [in dtxsql-java_92d3a23d] is not on its project's build path
Java Model Exception: Error in Java Model (code 1006): _/traceprofiler/src/test/java/com/xx/xx/traceprofiler [in dtxsql-java_92d3a23d] is not on its project's build path
    at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:584)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:254)
    at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:528)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:248)
    at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:528)
    at org.eclipse.jdt.internal.core.CompilationUnit.openAncestors(CompilationUnit.java:1246)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:248)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:597)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:328)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:314)
    at org.eclipse.jdt.internal.core.CompilationUnit.getSourceRange(CompilationUnit.java:961)
    at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.computeFoldingRanges(FoldingRangeHandler.java:79)
    at org.eclipse.jdt.ls.core.internal.handlers.FoldingRangeHandler.foldingRange(FoldingRangeHandler.java:70)
    at org.eclipse.jdt.ls.core.internal.syntaxserver.SyntaxLanguageServer.lambda$8(SyntaxLanguageServer.java:374)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

Contents of launch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch TraceProfiler",
            "request": "launch",
            "mainClass": "com.xx.xx.traceprofiler.TraceProfiler",
            "args": [ "trace.qoe.profiler.log" ],
            "projectName": "traceprofiler",
            "cwd": "${workspaceFolder}${pathSeparator}traceprofiler"
        }
    ]
}

Thanks

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20
Russ Petersen
  • 765
  • 1
  • 9
  • 29
  • Related: https://stackoverflow.com/a/6037405/11107541 and https://stackoverflow.com/q/31878498/11107541. Show your launch.json file. And check if the output logs show what command is being run to launch your JVM. I want to see the flags being passed – starball Apr 14 '23 at 20:34
  • What version of Java do you use? Try to replace the JDK version. – JialeDu Apr 17 '23 at 08:54
  • java --version java 18 2022-03-22 Java(TM) SE Runtime Environment (build 18+36-2087) Java HotSpot(TM) 64-Bit Server VM (build 18+36-2087, mixed mode, sharing) – Russ Petersen Apr 17 '23 at 15:22
  • I'd also encourage you to post this as a bug report to https://github.com/microsoft/vscode-java-debug and link us here to the issue ticket you create. That way we can also get the maintainers to look at it. – starball Apr 19 '23 at 17:14
  • This may sound crazy, but I had this exact problem yesterday. I'm using Spring, and today, I drilled into my Spring extension and started from there. It started. Thereafter I've been able to just click the usual green arrow to start. Go figure. – johnjps111 Apr 21 '23 at 17:33

1 Answers1

1

I have had the same error as you for a few weeks/months: Failed to launch debuggee VM. Reason: VM exited with status1 popup and ERROR: JDWP unable to get necessary JVMTI capabilities. message in the debug console when trying to debug a test method in VSCode.

In my case, here's the command line that is being executed by VSCode:

"C:\Program Files\Eclipse Adoptium\jdk-8.0.362.9-hotspot\bin\java.exe" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=localhost:59735,server=n,suspend=y -ea -Dfile.encoding=UTF-8 -cp [...my full classpath...];c:\ProgramData\VSCode\Code\User\globalStorage\redhat.java\1.17.0\config_win\org.eclipse.osgi\99\0\.cp;c:\ProgramData\VSCode\Code\User\globalStorage\redhat.java\1.17.0\config_win\org.eclipse.osgi\51\0\.cp org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 59732 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -test [...my test method...]

Running the same command from a command prompt outside of VSCode also results in this ERROR: JDWP unable to get necessary JVMTI capabilities. error message.

It seems that the issue is not only with tests. I had a project for which I had configured the launch configuration in launch.json with "console": "internalConsole", and it caused the same errors when trying to launch the program itself. I just removed that line and then it worked fine. But for the tests, I currently don't have a solution.


EDIT

I am not sure, but I suspect that the issue was somehow linked to SentinelOne (which is installed on my machine).

I uninstalled and reinstalled the SentinelOne agent, and I do not have the error anymore. Neither when debugging a test case nor when launching a project with "internalConsole" config.

Hope this information can be useful to the original asker or anyone else.

user630729
  • 23
  • 1
  • 5
  • nice. this may be useful for others with a similar problem, but for the record, do notice that the asker _here_ does not have `"console": "internalConsole"` in their launch config. – starball Apr 19 '23 at 17:12
  • This is 4 years old but I just ran into the same problem with the same sircumstances. My current remote work requires I installed SentinelOne on my work laptop. I can confirm that ever since it's installed I always get that same error "ERROR: JDWP unable to get necessary JVMTI capabilities" when debugging Java App from IDE. I use VSCode and the Java Debugger addon. SentinelOne is a centrally administered app there is no way I can temporary disable it for a debug session. This issue is very particular that this answer is the only one i can find referring to it – bluearth Aug 28 '23 at 12:24