dansomething / coc-java-debug

An extension for coc.nvim to enable Java debugging via jdt.ls
https://www.npmjs.com/package/coc-java-debug
Eclipse Public License 2.0
100 stars 8 forks source link

Stuck at Starting Java debug server.. #18

Closed sidmeister closed 3 years ago

sidmeister commented 3 years ago

Hi,

I followed the steps mentioned in the READMe but still unable to start the debug server.

Steps taken

  1. CocInstall coc-java
  2. Install Plugin 'puremourning/vimspector'
  3. CocInstall coc-java-debug
  4. Ran java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=28240,suspend=y Hello
  5. Open Hello.java Press F9 to start breakpoint.
  6. Ran command :CocCommand java.debug.vimspector.start

Nothing happned. When typed :messages all i see is [coc.nvim] Starting Java debug server...

Here is my :checkhealth report

health#coc#check

vim version: NVIM v0.4.3 node version: v12.13.0 coc.nvim version: 0.0.80-cc1ad56699 platform: darwin

Log of coc.nvim

2021-03-24T23:30:15.867 INFO (pid:29275) [coc-java] - Using java from /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home, version: 11 2021-03-24T23:30:15.905 INFO (pid:29275) [plugin] - coc.nvim 0.0.80-cc1ad56699 initialized with node: v12.13.0 after 246ms 2021-03-24T23:30:15.924 INFO (pid:29275) [coc-java] - JDT Language Server starting at /Users///****/learnJava 2021-03-24T23:30:15.925 INFO (pid:29275) [services] - registered service "java" 2021-03-24T23:30:15.930 INFO (pid:29275) [language-client-index] - Language server "java" started with 29277 2021-03-24T23:30:54.196 INFO (pid:29275) [attach] - receive notification: runCommand [ 'java.debug.vimspector.start' ] 2021-03-24T23:33:44.420 INFO (pid:29275) [attach] - receive notification: runCommand [ 'java.debug.vimspector.start' ] 2021-03-24T23:35:50.498 INFO (pid:29275) [attach] - receive notification: showInfo [] 2021-03-24T23:35:50.511 INFO (pid:29275) [attach] - receive request: CocAutocmd [ 'BufReadCmd', 'output', 'output:///info' ] 2021-03-24T23:44:48.065 INFO (pid:29275) [attach] - receive notification: showInfo []

Kindly help.

dansomething commented 3 years ago

I notice you are using port 28240 for Java debugging. Did you set that as the attach port value in your .vimspector.json file?

Also, it may help to look at some other logs. 1) View the trace logging output for the Java language server.

sidmeister commented 3 years ago

Yes but now I changed the port to 5005 to the example you had and still seeing the same issue. Here is my json

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

The :VimspectorShowOutput Vimspector says Vimspector is not active. I guess that's the issue. Would you be able to help on that?

On running :CocCommand java.debug.vimspector.start all I see is [coc.nvim] Starting Java Debug server

dansomething commented 3 years ago

You can choose any port number as long as it is not in use by another process and is the same value in the java command and the .vimspector.json file.

It sounds to me like there's an issue getting a response from the language server command to start the debug session. Can you check the Java language server trace logs? After you run :CocCommand java.debug.vimspector.start you should see messages similar to the following in the logs when tracing is set to verbose.

[Trace - 7:45:05 AM] Sending request 'workspace/executeCommand - (1)'.
Params: {
    "command": "vscode.java.startDebugSession",
    "arguments": []
}

[Trace - 7:45:05 AM] Received response 'workspace/executeCommand - (1)' in 21ms.
Result: 50479

You can see the first is the command to start the debug session while the second is the response containing the port number the session adapter is running on. This is the ${AdapterPort} that Vimspector needs to know about. If you don't see those messages what do you see? Are there any error messages?

Also, do you see initializationOptions in the Java language server trace logs? What value do you have for initializationOptions.bundles? It should look like this:

    "initializationOptions": {
        "bundles": [
            "/path/to/your/home/directory/.config/coc/extensions/node_modules/coc-java-debug/server/com.microsoft.java.debug.plugin-0.30.1.jar"
        ],
        ...
    }
sidmeister commented 3 years ago

Looking at executeCommand in :CocCommand java.debug.vimspector.start did the trick. My project was taking a lot of time to build and I was not being patient enough. I gave it time and now able to debug. Thank you for your help

dansomething commented 3 years ago

Cool, maybe I'll add a note to the readme to be sure to wait until the project build is complete before attempting to start the debug session. Perhaps I can find a way to detect if the build is still running or not.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed due to lack of activity.