weixin_39788051
weixin_39788051
2020-12-02 04:45

Java debugging broken on maven project on update to VScode 1.4.0

On auto update of the latest vscode (I think 1.4.0) debugging in Java was broken

Environment
  • Operating System: Windows 10 Enterprise 1809
  • JDK version: Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
  • Visual Studio Code version: 1.38.1 (same problem with 1.39 and 1.40)
  • Java extension version: Java Extension Pack 0.8.0
  • Java Debugger extension version: 0.23.0
Steps To Reproduce
  1. Install VS code from scratch
  2. Install the following extensions: Visual Studio IntelliCode, Language Support for Java (now 0.53), Java Extension Pack (now 0.8.0) which also installs Debugger for Java, Java Dependency Viewer, Java Test Runner, Maven for Java
  3. Create a simple hello world java class (called DebugTest in my case)

package com.sap.orca.settools.testdata; public class DebugTest { public static void main(String[] args) { System.out.println("hello world"); } }

  1. Select the Run code lens on main(String[] args) to run. Will work running the following:

c:\SAPDevelop\git\set-tools>cd c:\SAPDevelop\git\set-tools && C:\Users\i824431.vscode\extensions\vscjava.vscode-java-debug-0.23.0\scripts\launcher.bat "C:\Program Files\Java\jdk1.8.0_144\bin\java" -Dfile.encoding=UTF-8 -cp C:\Users\i824431\AppData\Local\Temp\cp_dt1ua77vkbfixhm0tw03ikc9h.jar com.sap.orca.settools.testdata.DebugTest hello world

  1. Hit F9 to put a breakpoint on the line System.out.println("hello world");

  2. Select the Debug code lens on main which throws the following exception

Exception has occurred: java.lang.ClassNotFoundException "java.lang.ClassNotFoundException: com.sap.orca.settools.testdata.DebugTest"

Here's the project file:

mh org.eclipse.jdt.core.javabuilder org.eclipse.m2e.core.maven2Builder org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature

Also here's my pom.xml which pre-existed

4.0.0

com.sap.mh mh 1.0-SNAPSHOT

mh

http://www.example.com

UTF-8 1.8 1.8

junit junit 4.11 test commons-codec commons-codec 1.13 com.googlecode.json-simple json-simple 1.1

maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 maven-surefire-plugin 2.22.1 maven-jar-plugin 3.0.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 maven-site-plugin 3.7.1 maven-project-info-reports-plugin 3.0.0

Here's the end of the java language server log file showing the problem

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-11-14 11:15:58.431 !MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod

!ENTRY java-debug 4 0 2019-11-14 11:15:58.518 !MESSAGE [error response][variables]: Failed to get variables. Reason: com.sun.jdi.InvalidStackFrameException !STACK 0 com.microsoft.java.debug.core.DebugException: Failed to get variables. Reason: com.sun.jdi.InvalidStackFrameException at com.microsoft.java.debug.core.adapter.AdapterUtils.createCompletionException(AdapterUtils.java:253) at com.microsoft.java.debug.core.adapter.handler.VariablesRequestHandler.handle(VariablesRequestHandler.java:118) at com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:85) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:981) at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2124) at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:84) 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:78) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jdi.InvalidStackFrameException at org.eclipse.jdi.internal.MirrorImpl.defaultReplyErrorHandler(MirrorImpl.java:294) at org.eclipse.jdi.internal.StackFrameImpl.getValues(StackFrameImpl.java:142) at org.eclipse.jdi.internal.StackFrameImpl.getValue(StackFrameImpl.java:78) at com.microsoft.java.debug.core.adapter.variables.VariableUtils.listLocalVariables(VariableUtils.java:153) at com.microsoft.java.debug.core.adapter.handler.VariablesRequestHandler.handle(VariablesRequestHandler.java:109) ... 17 more

Current Result

Get error Exception has occurred: java.lang.ClassNotFoundException "java.lang.ClassNotFoundException: com.sap.orca.settools.testdata.DebugTest"

Note I also get a similar error running tests. Run-ning a test works fine but debugging a test results in an error where the class for TestRunner cannot be found either.

Expected Result

Expect debugger to stop on the System.out.println statement

Additional Informations

This started happening immediately after the upgrade to 1.4.0. I had autoupdate on before and had updated in the last couple of weeks with no problem.

I have installed earlier versions of vscode 1.39 and 1.38 with the same problem. And I tried deleting all my local project files and .vscode directory in my user directory holding all the extensions. I think this is an extension problem.

I thinks that Language Support for Java just updated from 0.52 to 0.53 and maybe your extension updated as well.

This problem is in an existing project created with Maven. If I do the same thing with just the DebugTest file in src/org/abc and put it in that package then debugging works. So this appears to be some interaction with Maven.

该提问来源于开源项目:microsoft/vscode-java-debug

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39568653 weixin_39568653 5月前

    Maybe deleting the workspace storage helps? I have to delete it every time I close VSCode else I get over 1k errors.

    点赞 评论 复制链接分享
  • weixin_39955829 weixin_39955829 5月前

    Maybe deleting the workspace storage helps? I have to delete it every time I close VSCode else I get over 1k errors.

    I think, this issue is related to https://github.com/redhat-developer/vscode-java/pull/880

    点赞 评论 复制链接分享
  • weixin_39637370 weixin_39637370 5月前

    I update all java related extensions, then got following error:

    !ENTRY java-debug 4 0 2019-12-03 17:32:32.733 !MESSAGE [error response][variables]: Failed to get variables. Reason: com.sun.jdi.InvalidStackFrameException !STACK 0 com.microsoft.java.debug.core.DebugException: Failed to get variables. Reason: com.sun.jdi.InvalidStackFrameException at com.microsoft.java.debug.core.adapter.AdapterUtils.createCompletionException(AdapterUtils.java:253) at com.microsoft.java.debug.core.adapter.handler.VariablesRequestHandler.handle(VariablesRequestHandler.java:118) at com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:85) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:981) at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2124) at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:84) 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:78) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jdi.InvalidStackFrameException at org.eclipse.jdi.internal.MirrorImpl.defaultReplyErrorHandler(MirrorImpl.java:294) at org.eclipse.jdi.internal.StackFrameImpl.getValues(StackFrameImpl.java:142) at org.eclipse.jdi.internal.StackFrameImpl.getValue(StackFrameImpl.java:78) at com.microsoft.java.debug.core.adapter.variables.VariableUtils.listLocalVariables(VariableUtils.java:153) at com.microsoft.java.debug.core.adapter.handler.VariablesRequestHandler.handle(VariablesRequestHandler.java:109) ... 17 more

    点赞 评论 复制链接分享
  • weixin_39727336 weixin_39727336 5月前

    +1

    点赞 评论 复制链接分享
  • weixin_39632327 weixin_39632327 5月前

    +1

    点赞 评论 复制链接分享
  • weixin_39843078 weixin_39843078 5月前

    +1

    点赞 评论 复制链接分享
  • weixin_39612122 weixin_39612122 5月前

    Your issue is about "Failed to get variables. Reason: com.sun.jdi.InvalidStackFrameException", duplicated with https://github.com/microsoft/vscode-java-debug/issues/767. It will be addressed in the coming 0.27.0.

    Regarding debugging broken on maven project, could anyone share a sample project to help reproduce the issue?

    点赞 评论 复制链接分享
  • weixin_39568232 weixin_39568232 5月前

    This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

    点赞 评论 复制链接分享

相关推荐