最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin4浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论