Closed zenoli closed 9 months ago
Did you try rebuilding java-debug and vscode-java-test?
JavaElementLabels
and other classes were removed from eclipse.jdt.ls: https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2854
I suspect the debug components used it as runtime dependency.
I installed all three packages using Mason. I already tried reinstalling all three of them but it didn't fix anything.
Maybe mason uses incompatible packages. There's nothing to do in nvim-jdtls about this as far as I can tell
Thanks for looking into this. You are right, it seems there is ~PR open in the vscode-java-test repo~ which will hopefully get merged soon.
Edit: The mentioned PR is actually merged and v0.40.0 is avaiable. However they don't seem to provide the extension on their github release page anymore, which is probably why we cannot access them via mason (the registry was reading those files).
Edit2: For all Mason users, the current workaround is to build java-test v0.40.0 from source (as explained in the README.md). I can confirm that this version is compatible with jdtls v1.28.0
For Mason users this is what I did to disrupt my setup the least as possible:
~/[MASON_PATH]/packages/java-test
. Here you will find a handful of files and the extension
folder that contains the jar files.vscode-java-test
reponpm i
npm run build-plugin
mv extension extension-bkp
ln -s ./vscode-java-test extension
That's it, relaunch nvim and you are good to go 😄
Note: If you inspect the
manson-receipt.json
you fill find explicit references to the jar files that point to the previous versions. It should be ok if you don't modify those because the plugin that uses them utilises a glob expression.
Following @cladera sollution worked but I did had to update the target file definition on com.microsoft.java.test.target Eclipse repository for the 4.30 version in order to solve this problem when trying to build-plugin
Missing requirement: org.eclipse.jdt.ls.core 1.31.0.202312081723 requires 'osgi.bundle; org.eclipse.search.core 3.16.0' but it could not be found
@cladera solution worked for me, but for anyone allergic to installing and building locally with npm (took over 1GB...): Someone has created a mason registry with downloads for java-test. In general, that seems like a cleaner solution: https://github.com/mason-org/mason-registry/pull/3083#issuecomment-1842510410
This is how I use it in configuring jdtls
:
--ftplugin/java.lua:
local function get_bundles()
local mason_reg = require("mason-registry")
local function get_adapter_bundle()
local pkg = mason_reg.get_package("java-debug-adapter")
local pkg_install_path = pkg:get_install_path()
local pkg_jar_glob = pkg_install_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar"
local pkg_jar = vim.fn.glob(pkg_jar_glob, 1);
return pkg_jar
end
local function get_vscode_java_test_bundles()
local pkg = mason_reg.get_package("java-test")
local pkg_install_path = pkg:get_install_path()
local pkg_jars_glob = pkg_install_path .. "/extension/server/*.jar"
local pkg_jars = vim.fn.glob(pkg_jars_glob, 1);
local pkg_jars_list = vim.split(pkg_jars, "\n")
return pkg_jars_list
end
local bundles = {
get_adapter_bundle(),
};
vim.list_extend(bundles, get_vscode_java_test_bundles())
-- vim.notify("[JAVA bundles] " .. vim.inspect(bundles))
return bundles
end
local config = {
-- cmd = { ... },
-- on_attach = ... ,
-- rood_dir = ...,
-- settings = { ... },
-- ...
-- Language server `initializationOptions`
-- You need to extend the `bundles` with paths to jar files if you want to use additional eclipse.jdt.ls plugins.
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
init_options = {
bundles = get_bundles(),
},
}
jdtls.start_or_attach(config)
Not super clean to have in your config, but it works.
Seems like Mason installation works fine now.
https://github.com/mfussenegger/nvim-jdtls/issues/588#issuecomment-1906924527
I tried today with versions:
installed version v1.32.0
homepage https://github.com/eclipse/eclipse.jdt.ls
languages Java
categories LSP
executables jdtls
installed version 0.52.0
homepage https://github.com/microsoft/java-debug
languages Java
categories DAP
installed version 0.39.0
homepage https://github.com/microsoft/vscode-java-test
languages Java
categories DAP
and I am getting the same error. any idea of what I am missing?
@allancomar Have to tried java-test 0.40.0? It has been a while but IIRC the fix to my original issue was to move past 0.39.0 which you are using. The issue was that mason did not support updating to it until recently. In case you are using mason as well, try updating it. I also had to call :JdtlsWipeDataAndRestart
afterwards but everything works fine now for me.
LSP client configuration
Eclipse.jdt.ls version
1.28.0
Steps to Reproduce
Gradle setup:
Output of
./gradlew --version
:Dependencies
Steps to reproduce:
Expected Result
Running/picking/debugging tests work as expected.
Actual Result
A notifiaction
ERROR Error fetching test candidates: org/eclipse/jdt/ls/core/internal/hover/JavaElementLabels
appears.Using :JdtShowLogs I could see the following:
The plugin
org/eclipse/jdt/ls/core/internal/hover/JavaElementLabels
does not exist in v.1.28.0, hence the error. It used to exist in 1.27.1. Version v.1.27.1 worked perfectly fine for me.Let me know if this is a nvim-jdtls isssue or whether I should post the issue on v.1.28.0 directly.
And thanks for the awesome plugin :-)