Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get debugger to work #3

Closed
richi1807 opened this issue Apr 30, 2020 · 2 comments
Closed

Could not get debugger to work #3

richi1807 opened this issue Apr 30, 2020 · 2 comments
Labels
question Further information is requested

Comments

@richi1807
Copy link

Hi there,
I've been trying to get the debugger to work. But I keep running into errors. To me it looks like debug adaptor is sending requests with a wrong protocol. Logs below :-

Steps

  1. Load the project.

  2. Activate coc-debug-java plugin.

  3. Run :CocCommand java.debug.vimspector.start

  4. The splash screen opens up and says "Initializing debug adaptor" but never moves beyond it. Vim status bar (which i think shows JDT ls logs ) says "Request for initialization aborted: closing down".

  5. In the logs I see the error "Unable to start debug server"

  6. My vimspector settings :-

    {
    "adapters": {
    "java-debug-server": {
    "name": "vscode-java",
    "port": "4456"
    }
    },
    "configurations": {
    "Java Attach": {
    "adapter": "java-debug-server",
    "configuration": {
    "request": "attach",
    "host": "127.0.0.1",
    "port": "4455"
    },
    "breakpoints": {
    "exception": {
    "caught": "N",
    "uncaught": "N"
    }
    }
    }
    }
    }

@dansomething
Copy link
Owner

dansomething commented Apr 30, 2020

In the steps you listed I don't see that you have started the JVM process with remote debugging enabled. Can you confirm that it is running on port 4455 as listed in your .vimspector.json?

TL;DR
I'd expect your .vimspector.json to be:

{
  "adapters": {
    "java-debug-server": {
      "name": "vscode-java",
      "port": "${AdapterPort}"
    }
  },
  "configurations": {
    "Java Attach": {
      "adapter": "java-debug-server",
      "configuration": {
        "request": "attach",
        "host": "127.0.0.1",
        "port": "4455"
      },
      "breakpoints": {
        "exception": {
          "caught": "N",
          "uncaught": "N"
        }
      }
    }
  }
}

I notice you have the port under "adapters.java-debug-server.port" as 4456. That will need to be the port of the Java debug server that is started by jdt.ls. It starts on a random port which it sends back to the caller (this plugin). You can see by the value running :messages in Vim after the language server debug service has started. It will be something like [coc.nvim] Java debug server started on port: 59054.

By default the coc-java-debug plugin expects the "adapter" port value in your vimspector to be "${AdapterPort}". See here. This way the value can be replaced dynamically at runtime when Vimspector is launched from this plugin. This prevents you from having to set it each time.

Additionally, You may use a different template name in your vimspector config if you like by changing the coc-java-debug plugin setting.

@richi1807
Copy link
Author

Hello, the plugin works fine with the ${Adaptor} settings you mentioned. I did start the debugging server from gradle by running gradle test --tests <test name> --debug-jvm.

At first I had put the same value in ${Adaptor} port as the value where the debugging server started by gradle was listening and I was getting an error with JWDP handshake. This was expected because the ${Adaptor} port is the JDT.ls's debug server's port, which probably uses a different protocol.

I have one suggestion, if you could add a note on how debug-server works, then it would offer people more clarity into the vimspector settings, specifically around ${Adaptor} port.

Great work by the way. i don't see any reason to go back to IntelliJ again :)

dansomething pushed a commit that referenced this issue May 2, 2020
@dansomething dansomething added the question Further information is requested label Aug 18, 2020
@dansomething dansomething mentioned this issue May 3, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants