Closed Vliro closed 3 years ago
Given that you're calling jdtls.setup_dap({ hotcodereplace = 'auto' })
you can remove the dap.adapter.java
definition. setup_dap
adds it.
The error indicates that you're sending an array for a property that is supposed to be a string.
aused by: java.lang.IllegalStateException: Expected STRING but was BEGIN_ARRAY at path $.args
at com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:181)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:402)
How does the launch.json
configuration that you use for vscode look like? If that configuration works, you could re-use it. See :help dap-launch.json
Are you sure you understand what half of your configuration is doing? Looks like you copied pieces from my dotfiles that make little sense for most people.
Ok thanks, I will.
I understood the reason, it was hard to understand as to why it did that. It seems that the args should be a string but not an array. However, setting it as a string gives me the following error:
[ ERROR ] 2021-08-17T19:13:45+0200 ] /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:402 ] "17 Aug 2021, 19:13:45 [error response][launch]: Failed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in launch configuration.\nFailed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in launch configuration.\ncom.microsoft.java.debug.core.DebugException: Failed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in launch configuration.\n\tat com.microsoft.java.debug.core.adapter.AdapterUtils.createCompletionException(AdapterUtils.java:250)\n\tat com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handleLaunchCommand(LaunchRequestHandler.java:89)\n\tat com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handle(LaunchRequestHandler.java:81)\n\tat com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:89)\n\tat java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)\n\tat java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)\n\tat com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:88)\n\tat com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:118)\n\tat com.microsoft.java.debug.core.protocol.AbstractProtocolServer.lambda$new$0(AbstractProtocolServer.java:78)\n\tat io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)\n\tat io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200)\n\tat io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252)\n\tat io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)\n\tat io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:829)\n"
{ "type": "java", "name": "runClient", "request": "launch", "mainClass": "net.minecraftforge.userdev.LaunchTesting", "projectName": "GregTech", "cwd": "${workspaceFolder}/run", "vmArgs": "-Dforge.logging.console.level=debug -Dforge.logging.markers=DEBUG -Dmixin.env.remapRefMap=true -Dmixin.env.refMapRemappingFile=/home/abbe/Dev/GregTech/build/createSrgToMcp/output.srg", "args": "-mixin.config=antimatter.mixins.json", "env": { "MOD_CLASSES": "gti%%/home/abbe/Dev/GregTech/bin/main:gti%%/home/abbe/Dev/GregTech/bin/main:antimatter%%/home/abbe/Dev/GregTech/AntimatterAPI/bin/main:antimatter%%/home/abbe/Dev/GregTech/AntimatterAPI/bin/main:tesseract%%/home/abbe/Dev/GregTech/AntimatterAPI/TesseractAPI/bin/main:tesseract%%/home/abbe/Dev/GregTech/AntimatterAPI/TesseractAPI/bin/main", "MCP_MAPPINGS": "snapshot_20210309-1.16.5", "MCP_VERSION": "20210115.111550", "FORGE_VERSION": "36.1.4", "assetIndex": "1.16", "assetDirectory": "/home/abbe/.gradle/caches/forge_gradle/assets", "nativesDirectory": "${workspaceFolder}/build/natives", "FORGE_GROUP": "net.minecraftforge", "target": "fmluserdevclient", "MC_VERSION": "1.16.5" } }
I mostly copied the launch config from vs code! It works just fine in VS code with jdtls.
Yes, I understand I copied most of it. I am simply trying to get it to work, and then simplify and remove unnecessary things or just rewrite completely!
Missing mainClass or modulePaths/classPaths options in launch configuration
Looks like now the module paths / class paths are missing. If you remove dap.adapters.java
from your configuration and instead rely on jdtls.setup_dap({ hotcodereplace = 'auto' })
it should setup an adapter definition that should be able to resolve these automatically.
Thank you, that was indeed the issue! It now launches the program. Next up is breakpoints!
Hi, I started using Java debug again and ran into some new issues. The base is Lunarvim with reconfigured java. Java ftplugin
-- if require("utils").check_lsp_client_active "jdt.ls" then
-- return
-- end
local status, jdtls = pcall(require,"jdtls")
if not status then
return
end
local home = os.getenv('HOME')
local debug_path = "/Documents/Code/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar"
-- find_root looks for parent directories relative to the current buffer containing one of the given arguments.
if vim.fn.has "mac" == 1 then
WORKSPACE_PATH = home .. "/workspace/"
elseif vim.fn.has "unix" == 1 then
WORKSPACE_PATH = home .. "/workspace/"
else
print "Unsupported system"
end
local root_markers = {'gradlew', '.git'}
local root_dir = require('jdtls.setup').find_root(root_markers)
JAVA_LS_EXECUTABLE = home .. "/.local/share/lunarvim/lvim/utils/bin/jdtls"
require("jdtls").start_or_attach {
on_attach = function (client, bufnr)
require("lsp").common_on_attach(client, bufnr)
jdtls.setup.add_commands()
jdtls.setup_dap({ hotcodereplace = 'auto' })
end,
init_options = {
bundles = {
vim.fn.glob(home .. debug_path)
};
},
flags = {
allow_incremental_sync = true,
};
cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(root_dir, ":p:h:t") },
settings = {
java = {
signatureHelp = { enabled = true };
contentProvider = { preferred = 'fernflower' };
codeGeneration = {
toString = {
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}"
}
};
},
configuration = {
runtimes = {
{
name = "JavaSE-11",
path = "/usr/lib/jvm/java-11-openjdk/",
},
{
name = "JavaSE-15",
path = "/usr/lib/jvm/java-15-openjdk/",
},
}
};
}
}
vim.api.nvim_set_keymap("n", "<leader>la", ":lua require('jdtls').code_action()<CR>", { noremap = true, silent = true })
vim.cmd "command! -buffer JdtCompile lua require('jdtls').compile()"
vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()"
-- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()"
vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()"
-- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()"
I use the provided vs code extension in nvim dap to load java launch configurations.
{
"type": "java",
"name": "runClient",
"request": "launch",
"mainClass": "net.minecraftforge.userdev.LaunchTesting",
"projectName": "GT-4-Reimagined",
"cwd": "${workspaceFolder}/run",
"vmArgs": "-Dforge.logging.console.level\u003ddebug -Dforge.logging.markers\u003dDEBUG -Dmixin.env.remapRefMap\u003dtrue -Dmixin.env.refMapRemappingFile\u003d/home/albert/Documents/Code/GT-4-Reimagined/build/createSrgToMcp/output.srg",
"args": "-mixin.config\u003dgt4r.mixins.json -mixin.config\u003dantimatter.mixins.json",
"env": {
"MOD_CLASSES": "gt4r%%/home/albert/Documents/Code/GT-4-Reimagined/bin/main:gt4r%%/home/albert/Documents/Code/GT-4-Reimagined/bin/main:antimatter%%/home/albert/Documents/Code/GT-4-Reimagined/AntimatterAPI/bin/main:antimatter%%/home/albert/Documents/Code/GT-4-Reimagined/AntimatterAPI/bin/main",
"MCP_MAPPINGS": "snapshot_20210309-1.16.5",
"MCP_VERSION": "20210115.111550",
"FORGE_VERSION": "36.2.2",
"assetIndex": "1.16",
"assetDirectory": "/home/albert/.gradle/caches/forge_gradle/assets",
"nativesDirectory": "${workspaceFolder}/build/natives",
"FORGE_GROUP": "net.minecraftforge",
"target": "fmluserdevclient",
"MC_VERSION": "1.16.5"
}
},
Loaded with
require('dap.ext.vscode').load_launchjs()
Also loaded manually rewriting JSON to lua. It launches occasionally but most of time it does not work.
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
Error executing vim.schedule lua callback: ...are/lunarvim/site/pack/packer/start/nvim-dap/lua/dap.lua:656: Adapter used with attach must have a port property
Error executing vim.schedule lua callback: ...are/lunarvim/site/pack/packer/start/nvim-dap/lua/dap.lua:656: Adapter used with attach must have a port property
Error executing vim.schedule lua callback: ...are/lunarvim/site/pack/packer/start/nvim-dap/lua/dap.lua:656: Adapter used with attach must have a port property
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or `java` configuration. Check the logs for errors (:help dap.set_log_level)
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:599: handle 0x560908df4470 is already closing
This time it did launch but most of the time it doesn't work. Also the session cannot be closed in any way and nvim has to be restarted. Also, when it launches like this it doesn't properly close the session (callbacks for e.g. gui are not called). What could be the reason? The LSP itself works great. I recall mentioning the classpaths which are not set afaik in this case. If there is more information needed I will happily provide.
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
Error executing vim.schedule lua callback: ...rvim/site/pack/packer/start/nvim-jdtls/lua/jdtls/dap.lua:42: attempt to index local 'paths' (a nil value)
The error here sounds like there is a problem with the debug adapter installation?
As far as I can tell, there shouldn't be a case where paths
is nil, the server component always returns a result:
The issue with the handle 0x... is already closing
should be fixed with https://github.com/mfussenegger/nvim-dap/pull/304 - I had this locally already for a while but had forgotten to push it.
Hello again!
I'm using the on_attach callback, jdtls.setup_dap function. Which should setup the proper adapters. The bundled added to java debug is /home/albert/Documents/Code/java-debug/com.microsoft.java.debug.plugin/t arget/com.microsoft.java.debug.plugin-0.32.0.jar
which should be enough to enable debug. Other than this I am not sure what is required to setup the debug. Is the load_launchjs supported for java configs?
I'd bet the other errors(handle is already closing) etc. stems from the initial error which breaks the debug session, the "attempt to index local paths." My run configurations do not have classPath or modulePath in it as a table value.
Do you have a branch in the project with the launch.json or so, so that I could try to reproduce it?
Hi,
There is a Gradle task, ./gradlew genVSCodeRuns. The project can be cloned with its submodules, which should be enough.
https://github.com/Trinsdar/GT-4-Reimagined is the repo I was using at the time of testing.
I get a build.gradle|1 col 1| Unresolved dependency: project AntimatterAPI
error in that project. Looks like the dependencies are not setup correctly?
Now it works for some reason, not changing anything. Thank you for your help.
LSP client configuration
My LSP config.
Eclipse.jdt.ls version
1.2.3
Steps to Reproduce
I have a project https://github.com/GregTech-Intergalactical/GregTech/ with subproject https://github.com/GregTech-Intergalactical/AntimatterAPI and https://github.com/GregTech-Intergalactical/TesseractAPI .It works in VS code. running ./gradlew runClient will start the program as usual, outside of nvim.
Expected Result
It should start a debug session. Instead complains that the adapter doesn't respond.
Actual Result