You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Help needed: Can't find documentation to configure Java Attach to Process Debug #340
This is automatically configured when you open a Java file. If you want custom configuration then you have to use dap APIs to do so. It's not in the scope of this project.
This is automatically configured when you open a Java file. If you want custom configuration then you have to use dap APIs to do so. It's not in the scope of this project.
The problem is that this plugin is overriding completely require'dap'.configurations.java on LspAttach, so it doens't matter if users are creating custom configurations, this plugin overrides them.
To fix this, instead of setting require'dap'.configurations.java directly
localdap=require'dap'dap.configurations.java=dap.configurations.javaor {} -- define the array of configurations only if not previously defined-- do this in a for loop for each discovered configurationtable.insert(dap.configurations.java, {
-- some discovered configuration
})
I have updated the plugin, and now my custom configuration (Attach to process) shows up in the :DapContinue options.
However, when I execute it, I get the following error:
Error executing vim.schedule lua callback: ...e/nvim/lazy/nvim-java-core/lua/java-core/utils/async.lua:41: unhandled error ...share/nvim/lazy
/nvim-java-dap/lua/java-dap/api/setup.lua:50: To enrich the config, mainClass should already be present
stack traceback:
[C]: in function 'error'
...e/nvim/lazy/nvim-java-core/lua/java-core/utils/async.lua:41: in function 'callback'
...nvim-java-core/lua/java-core/ls/clients/jdtls-client.lua:72: in function 'handler'
.../neovim/0.10.3/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
nvim-jdtls (the other java plugin for nvim from the same creator of nvim-dap) seems to discover the main clases during enrich_dap_config instead of before, like nvim-java (which is throwing an error because it expects those fields to be there). I don't know enough about how the java debug adapter works to help here, but nvim-jdtls has always worked for me, so I guess nvim-java-dap has to be modified to do the discovering of main classes later (?)
I don't know if this helps, but the directory I am opening has multiple Java projects in the subdirectories.
Also, I don't understand why there needs to be a main class (or class with a main method) altogether since I am going to use "Attach to Debug" in a Spring MVC project where there's no custom class with a main method.
As a workaround adding the mainClass field to the debug configuration by hand will resolve this. The value should be the fully qualified reference to the main class, e.g. com.organization.foo.FooApplication.
Thanks for the suggestion, I appreaciate it. I use Spring MVC, so there's no main class, rather it's deployed on a web server like Tomcat and then we "Attach" to Debug
Activity
s1n7ax commentedon Jan 7, 2025
This is automatically configured when you open a Java file. If you want custom configuration then you have to use dap APIs to do so. It's not in the scope of this project.
s1n7ax commentedon Jan 7, 2025
If what you are trying to say is that debug is not working out of the box, then i could look into it
me-heer commentedon Jan 7, 2025
If attach to process configuration is automatically configured, how do I invoke it?
:DapContinue only shows classes which have main method in them, and there's no debug configuration of attaching to a process
TheLeoP commentedon Jan 8, 2025
The problem is that this plugin is overriding completely
require'dap'.configurations.javaonLspAttach, so it doens't matter if users are creating custom configurations, this plugin overrides them.To fix this, instead of setting
require'dap'.configurations.javadirectlynvim-java/lua/java/dap/init.lua
Line 108 in e8e8441
a better approach would be to
s1n7ax commentedon Jan 8, 2025
I would happily accept this PR
me-heer commentedon Jan 10, 2025
Thanks for the help.
I have updated the plugin, and now my custom configuration (Attach to process) shows up in the :DapContinue options.
However, when I execute it, I get the following error:
I have gone through the Trobleshooting section and applied this: https://github.com/nvim-java/nvim-java/wiki/Troubleshooting#no_entry-to-enrich-the-config-xxx-should-already-be-present
My configuration for reference: https://github.com/me-heer/nvim/blob/master/init.lua#L1056-L1065
TheLeoP commentedon Jan 10, 2025
nvim-jdtls (the other java plugin for nvim from the same creator of nvim-dap) seems to discover the main clases during
enrich_dap_configinstead of before, likenvim-java(which is throwing an error because it expects those fields to be there). I don't know enough about how the java debug adapter works to help here, butnvim-jdtlshas always worked for me, so I guessnvim-java-daphas to be modified to do the discovering of main classes later (?)me-heer commentedon Jan 10, 2025
I don't know if this helps, but the directory I am opening has multiple Java projects in the subdirectories.
Also, I don't understand why there needs to be a main class (or class with a main method) altogether since I am going to use "Attach to Debug" in a Spring MVC project where there's no custom class with a main method.
agraven commentedon Jun 16, 2025
As a workaround adding the
mainClassfield to the debug configuration by hand will resolve this. The value should be the fully qualified reference to the main class, e.g.com.organization.foo.FooApplication.me-heer commentedon Jun 18, 2025
Thanks for the suggestion, I appreaciate it. I use Spring MVC, so there's no main class, rather it's deployed on a web server like Tomcat and then we "Attach" to Debug