jvm - Error when trying to attach remote debugger with nvim-dap and Java - Stack Overflow

I'm trying to set up remote debugging for a Java application in Neovim using nvim-dap. However, wh

I'm trying to set up remote debugging for a Java application in Neovim using nvim-dap. However, when I try to attach the debugger, I get the following error:

Error 09:21:30 notify.error DAP Error on attach: Failed to attach to remote debuggee VM. Reason: java.ConnectException: Connection refused

Neovim Configuration

I'm using the extra plugin lang.java from LazyVim, which contains the following configuration for nvim-dap:

  {
    "mfussenegger/nvim-dap",
    optional = true,
    opts = function()
      local dap = require("dap")
      dap.configurations.java = {
        {
          type = "java",
          request = "attach",
          name = "Debug (Attach) - Remote",
          hostName = "127.0.0.1",
          port = 5005,
        },
      }
    end,
    dependencies = {
      {
        "williamboman/mason.nvim",
        opts = { ensure_installed = { "java-debug-adapter", "java-test" } },
      },
    },
  }

What I Tried

If I manually start the JVM with the following command before attaching the debugger, nvim-dap works correctly:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -cp bin exemplo.Autodromo

This makes the JVM start and wait on port 5005:

Listening for transport dt_socket at address: 5005

But if I try to start the debugger in Neovim without this manual step, I get the "Connection refused" error.

Question

What could be causing this issue? Is there any additional configuration I need to adjust so that nvim-dap can correctly attach to the Java process without manually starting the JVM with -agentlib:jdwp?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744193923a4562561.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信