microsoft / microsoft/vscode-java-debug

debug maven app locally does not work with the java debug extension

未关闭
#1,525 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

ai-triaged question
主要语言
TypeScript
星标
591
派生
429
平均合并
1 天 9 小时
30 天内合并 PR
19

描述

Hi, we have a maven app, which is deployed to the mainframe, and we building our own application to fit Java Maven apps into our vscode workflow.

So we need to debug java maven apps for quarkus (maybe open liberty) and for mainframe batch.

To Debug the app local i used this minimal snippet which is working fine in eclipse...

@Dependent
public class BGZ50FileCreator extends JhapBatchApp {

    private final static String appName = "VOR_BGZ50";
    @Override
    public String getAppName() {
        return appName;
    }

    @Override
    public void run() throws CheckedBusinessException {
        System.out.println("Hello World");
    }   
}

In Vscode this exception is thrown before "Hello World" is printed

Unable to invoke public void  at.mysecretlib.init()  
...
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.NullPointerException

Image

When comparing eclipse and vscode command for debug:

eclipse:

C:\mypath\jdk\1.8.0.262-3.b10.redhat.windows.x86_64\bin\javaw.exe -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:62642 "-javaagent:C:\mypath2\configuration\org.eclipse.osgi\424\0.cp\lib\javaagent-shaded.jar" -Dfile.encoding=UTF-8 -classpath
"C:\mymaven\at\mytool\mytool-batch\2.171.6\mytool-batch-2.171.6.jar;
....
at.mytoolx.batch.mytoolAppLoader VOR_BGZ50

vscode:

c:\mypath\jdk\1.8.0.262-3.b10.redhat.windows.x86_64\bin\javaw.exe' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:50209' '-cp' 'C:\myrepo\myproject\target\classes; C:\mymave\at\mytool\mytool-batch\2.171.6\mytool-batch-2.171.6.jar;
...
'at.mytoolx.batch.mytoolAppLoader' 'VOR_BGZ50'

The noteable differences are the missing javaagent, the additional "server=n" and an additional entry as first argument in classpath.

launch.config (in workspace file)

    "configurations": [
      {
        "type": "java",
        "name": "Java",
        "request": "launch",
        "mainClass": "at.mytoolx.batch.mytoolAppLoader",
        "projectName": "myproject",
        "args": "VOR_BGZ50",
        "javaExec": "c:\\mypath\\jdk\\1.8.0.262-3.b10.redhat.windows.x86_64\\bin\\javaw.exe",
        "shortenCommandLine": "none",
      }

Thanks!

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 workspace launch.config 中的 mainClass at.mytoolx.batch.mytoolAppLoader 开始,并比较报告中显示的 Eclipse 和 VS Code Java 命令行。使用提供的 VOR_BGZ50 参数重现本地调试启动,然后检查 Java debug extension 如何构建 classpath 和调试选项。当应用程序在 VS Code 中到达 "Hello World" 且不再出现报告中的初始化异常时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, vscode
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。