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

The installation instructions for vscode-java-test lead to an error during jdtls-nvim initialization. #746

Open
apechinsky opened this issue Jan 24, 2025 · 1 comment

Comments

@apechinsky
Copy link

Discussed in #745

Originally posted by apechinsky January 23, 2025
The installation instructions for vscode-java-test lead to an error during jdtls-nvim initialization.

Configuration

vim.list_extend(bundles, vim.split(vim.fn.glob("/path/to/microsoft/vscode-java-test/server/*.jar", 1), "\n"))
config['init_options'] = {
  bundles = bundles;
}

JdtShowLogs

[ERROR][2025-01-23 13:18:13] ...lsp/handlers.lua:623	"Jan 23, 2025, 1:18:12 PM Failed to load extension bundles 
Load bundle list
org.eclipse.core.runtime.CoreException: Load bundle list
\tat org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.loadBundles(BundleUtils.java:173)
\tat org.eclipse.jdt.ls.core.internal.handlers.InitHandler.handleInitializationOptions(InitHandler.java:113)
\tat org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.initialize(BaseInitHandler.java:68)
\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.initialize(JDTLanguageServer.java:284)
\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)
\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:65)
\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:128)
\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:271)
\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:201)
\tat org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$1(ParentProcessWatcher.java:144)
\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:185)
\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:97)
\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:114)
\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
\tat java.base/java.lang.Thread.run(Thread.java:833)
Contains: Failed to get bundleInfo for bundle from /home/user/.local/share/nvim/mason/packages/java-test/extension/server/com.microsoft.java.test.runner-jar-with-dependencies.jar
Contains: Failed to get bundleInfo for bundle from /home/user/.local/share/nvim/mason/packages/java-test/extension/server/jacocoagent.jar

The problem is that the configuration adds all vscode-java-test JARs as bundles, but some of them are not OSGi bundles:

  • com.microsoft.java.test.runner-jar-with-dependencies.jar
  • jacocoagent.jar

These files don't contain bundle information in the META-INF/MANIFEST.MF file.

eclipse.jdt.ls tries to access the missing Bundle-Version property:
https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BundleUtils.java#L335

and throws an exception:
https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BundleUtils.java#L175

Solution

Exclude the listed JARs from the bundle list.

@fromSmolsoft
Copy link

fromSmolsoft commented Feb 18, 2025

I "glued" together (temporary?) automated bundle filtering for wildcard bundles loading while dealing with same issue. If anyone finds it useful feel free to use it.

        -- Your bundles collection
        local bundles = vim.split(vim.fn.glob(mason_path .. "packages/java-*/extension/server/*.jar", 1),
            '\n')
        -- Paste it after bundles but before assigning bundles to jdtls
        -- Following filters out unwanted bundles
        local ignored_bundles = { "com.microsoft.java.test.runner-jar-with-dependencies.jar", "jacocoagent.jar" }
        local find = string.find
        local function should_ignore_bundle(bundle)
            for _, ignored in ipairs(ignored_bundles) do
                if find(bundle, ignored, 1, true) then
                    return true
                end
            end
        end
        bundles = vim.tbl_filter(function(bundle) return bundle ~= "" and not should_ignore_bundle(bundle) end, bundles)

I'm sure there is better way but this seems to work good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants