mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.05k stars 61 forks source link

java.nio.file.FileSystemNotFoundException: Provider "jdt" not installed #469

Closed sledigabel closed 1 year ago

sledigabel commented 1 year ago

LSP client configuration

This is my ftplugin/java.lua file:

local_dir = vim.fn.getcwd()
local local_dir_name = vim.fn.fnamemodify(local_dir, ":p:h:t")
local workspace_dir = os.getenv("HOME") .. "/workspaces/" .. local_dir_name

-- adding addition text support capabilities
local extendedClientCapabilities = require("jdtls").extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true

-- eclipse jdtls settings
local settings = {
  java = {
    signatureHelp = { enabled = true },
    contentProvider = { preferred = "fernflower" },
    completion = {
      favoriteStaticMembers = {
        "org.hamcrest.MatcherAssert.assertThat",
        "org.hamcrest.Matchers.*",
        "org.hamcrest.CoreMatchers.*",
        "org.junit.jupiter.api.Assertions.*",
        "java.util.Objects.requireNonNull",
        "java.util.Objects.requireNonNullElse",
        "org.mockito.Mockito.*",
      },
      filteredTypes = {
        "com.sun.*",
        "io.micrometer.shaded.*",
        "java.awt.*",
        "jdk.*",
        "sun.*",
      },
    },
    sources = {
      organizeImports = {
        starThreshold = 9999,
        staticStarThreshold = 9999,
      },
    },
    codeGeneration = {
      toString = {
        template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
      },
      hashCodeEquals = {
        useJava7Objects = true,
      },
      useBlocks = true,
    },
    configuration = {},
  },
}

local config = {
  -- cmd for the jdtls package
  cmd = {
    "jdtls",
    "--jvm-args=-Dlog.level=ALL",
    "--jvm-args=-Dlog.protocol=true",
    "-data",
    workspace_dir,
  },

  settings = settings,

  root_dir = local_dir,
  init_options = {
    extendedClientCapabilities = extendedClientCapabilities,
    bundles = {},
  },

  on_init = function(client)
    client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
  end,
}
vim.lsp.set_log_level("debug")
require("jdtls.setup").add_commands()
require("jdtls").start_or_attach(config)

I use lazy.nvim to load the module, config looks like this:

return {
  "mfussenegger/nvim-jdtls",
  lazy = true,
}

I'm using jdtls from homebrew, but the behaviour is the same when I use a manually installed jdtls.

Version of java is:

openjdk 17.0.4.1 2022-08-12
OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode)

Eclipse.jdt.ls version

1.21.0

Steps to Reproduce

Open a java project, and go to definition on a class that's not defined in the project.

Expected Result

The plugin should resolve the definition and use jdtls to unpack and show the class file in neovim for navigation using the jdt:// access pattern.

Hovers, go to definitions, code actions etc work otherwise fine within the project.

This might be something stupid with my config, just been looking at fixing this for a while now, thanks for helping and thanks for this awesome project! 😎

Actual Result

I'm getting an error on jdtls:

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-04-19 14:05:43.996
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-04-19 14:05:43.997
!MESSAGE Error getting content via disassemblerContentProvider
!STACK 0
java.nio.file.FileSystemNotFoundException: Provider "jdt" not installed
    at java.base/java.nio.file.Path.of(Path.java:212)
    at java.base/java.nio.file.Paths.get(Paths.java:98)
    at org.eclipse.jdt.ls.core.internal.DisassemblerContentProvider.getContent(DisassemblerContentProvider.java:41)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:110)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:81)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$26(JDTLanguageServer.java:886)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
mfussenegger commented 1 year ago

Open a java project, and go to definition on a class that's not defined in the project.

Are you accessing a JDK file, a class for which there are sources, or a class that needs to be decompiled? eclipse.jdt.ls has different content-providers for these cases.

My guess is you're defining contentProvider = { preferred = "fernflower" }, but don't have it installed. Try removing it.

sledigabel commented 1 year ago

Thanks a ton @mfussenegger for the pointers, I tried removing it and the result is unchanged; any tip on how to install fernflower or ECD on jdtls? Most documentation would add it through the eclipse IDE.

mfussenegger commented 1 year ago

Clone https://github.com/dgileadi/vscode-java-decompiler and add the paths to the jars from the server/ folder to the bundles in your config.

But it should only be used for cases where you don't have the sources.

sledigabel commented 1 year ago

Making some progress here, Thanks for your patience on this 🙇 this time fernflower is found and used but fails with the same error still. Then it tried via cfr, the next provider on the list.

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-04-25 00:00:40.853
!MESSAGE >> java/classFileContents

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-04-25 00:00:40.854
!MESSAGE Error getting content via fernflower
!STACK 0
java.nio.file.FileSystemNotFoundException: Provider "jdt" not installed
    at java.base/java.nio.file.Path.of(Path.java:212)
    at java.base/java.nio.file.Paths.get(Paths.java:98)
    at dg.jdt.ls.decompiler.fernflower.BytecodeProvider.loadBytecode(BytecodeProvider.java:55)
    at dg.jdt.ls.decompiler.fernflower.BytecodeProvider.getBytecode(BytecodeProvider.java:46)
    at org.jetbrains.java.decompiler.struct.lazy.LazyLoader.getClassStream(LazyLoader.java:116)
    at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:107)
    at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:63)
    at org.jetbrains.java.decompiler.main.Fernflower.addSource(Fernflower.java:73)
    at org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler.addSource(BaseDecompiler.java:21)
    at dg.jdt.ls.decompiler.fernflower.FernflowerDecompiler.getContent(FernflowerDecompiler.java:81)
    at dg.jdt.ls.decompiler.fernflower.FernflowerDecompiler.decompileContent(FernflowerDecompiler.java:68)
    at dg.jdt.ls.decompiler.common.CachingDecompiler.getContent(CachingDecompiler.java:34)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:110)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:81)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$26(JDTLanguageServer.java:886)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-04-25 00:00:40.855
!MESSAGE Error getting content via cfr
!STACK 0
java.nio.file.FileSystemNotFoundException: Provider "jdt" not installed
    at java.base/java.nio.file.Path.of(Path.java:212)
    at dg.jdt.ls.decompiler.cfr.CFRDecompiler.decompileContent(CFRDecompiler.java:75)
    at dg.jdt.ls.decompiler.common.CachingDecompiler.getContent(CachingDecompiler.java:34)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:110)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:81)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$26(JDTLanguageServer.java:886)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

I also tried with another plugin, ECD, it still fails at the decompile time with "provider jdt not installed". Really puzzled here... I've tried with running eclipse jdt as a raw jar, or the jdtls wrapper from homebrew, same result. The FileSystemNotFoundException seems to indicate that it's the jdt access to the class that's problematic. I'm assuming this is the jdt:// path pattern?

sledigabel commented 1 year ago

Hello again, making progress :-) Found that before the jdt search happens and fails, there's an error during the jdtls initialisation:

!ENTRY org.sf.feeling.decompiler.cfr 4 0 2023-04-26 18:58:13.361
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.sf.feeling.decompiler.cfr [77]
  Unresolved requirement: Require-Bundle: org.eclipse.jface
  Unresolved requirement: Require-Bundle: org.sf.feeling.decompiler
    -> Bundle-SymbolicName: org.sf.feeling.decompiler; bundle-version="3.1.1.201811062102"; singleton:="true"
       org.sf.feeling.decompiler [82]
         Unresolved requirement: Require-Bundle: org.eclipse.jface

    at org.eclipse.osgi.container.Module.start(Module.java:463)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

!ENTRY org.sf.feeling.decompiler.jad 4 0 2023-04-26 18:58:13.371
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.sf.feeling.decompiler.jad [78]
  Unresolved requirement: Require-Bundle: org.eclipse.jface
  Unresolved requirement: Require-Bundle: org.sf.feeling.decompiler
    -> Bundle-SymbolicName: org.sf.feeling.decompiler; bundle-version="3.1.1.201811062102"; singleton:="true"
       org.sf.feeling.decompiler [82]
         Unresolved requirement: Require-Bundle: org.eclipse.jface

    at org.eclipse.osgi.container.Module.start(Module.java:463)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

!ENTRY org.sf.feeling.decompiler.jd 4 0 2023-04-26 18:58:13.372
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.sf.feeling.decompiler.jd [79]
  Unresolved requirement: Require-Bundle: org.eclipse.jface
  Unresolved requirement: Require-Bundle: org.sf.feeling.decompiler
    -> Bundle-SymbolicName: org.sf.feeling.decompiler; bundle-version="3.1.1.201811062102"; singleton:="true"
       org.sf.feeling.decompiler [82]
         Unresolved requirement: Require-Bundle: org.eclipse.jface

    at org.eclipse.osgi.container.Module.start(Module.java:463)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

!ENTRY org.sf.feeling.decompiler.procyon 4 0 2023-04-26 18:58:13.372
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.sf.feeling.decompiler.procyon [80]
  Unresolved requirement: Require-Bundle: org.eclipse.jface
  Unresolved requirement: Require-Bundle: org.sf.feeling.decompiler
    -> Bundle-SymbolicName: org.sf.feeling.decompiler; bundle-version="3.1.1.201811062102"; singleton:="true"
       org.sf.feeling.decompiler [82]
         Unresolved requirement: Require-Bundle: org.eclipse.jface

    at org.eclipse.osgi.container.Module.start(Module.java:463)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)

I've walked down the painful path of adding individual jars (org.eclipse.jface, then org.eclipse.ui.editors etc.) and stopped at the 7th iteration. Surely there's a step I've missed in the process...

JDTLS was installed with homebrew, but tried as well with downloading a milestone release from github. I'll try the way you've done it from your ansible playbook, i.e. downloading the source code and building it, see if it makes any difference.

sledigabel commented 1 year ago

Hello again,

On a clean install of jdt.ls, I'm getting again the origin error. Installing the vscode-java-decompiler is successful, but the decompilation fails again:

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:25.316
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is stopping:
!SESSION 2023-05-01 21:12:33.654 -----------------------------------------------
eclipse.buildId=unknown
java.version=17.0.4.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=macosx, ARCH=aarch64, WS=cocoa, NL=en_GB
Framework arguments:  --jvm-args=-Dlog.level=ALL --jvm-args=-Dlog.protocol=true
Command-line arguments:  -data /Users/sebastienledigabel/workspaces/testjavaservice --jvm-args=-Dlog.level=ALL --jvm-args=-Dlog.protocol=true

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.183
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.276
!MESSAGE Main thread is waiting

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.292
!MESSAGE >> initialize

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.293
!MESSAGE Initializing Java Language Server 1.24.0.202304282148

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.309
!MESSAGE Installed reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.cfr-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.314
!MESSAGE Installed reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.common-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.325
!MESSAGE Installed reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.fernflower-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.334
!MESSAGE Installed reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.procyon-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.358
!MESSAGE Started reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.fernflower-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.398
!MESSAGE Started reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.procyon-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.404
!MESSAGE Started reference:file:/Users/sebastienledigabel/.config/nvim/java/vscode-java-decompiler/server/dg.jdt.ls.decompiler.cfr-0.0.3.jar

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.422
!MESSAGE Static Commands: []

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.423
!MESSAGE Non-Static Commands: [java.edit.organizeImports, java.project.refreshDiagnostics, java.project.import, java.navigate.openTypeHierarchy, java.project.removeFromSourcePath, java.project.listSourcePaths, java.project.resolveStackTraceLocation, java.project.getAll, java.reloadBundles, java.project.isTestFile, java.edit.handlePasteEvent, java.project.getClasspaths, java.navigate.resolveTypeHierarchy, java.edit.stringFormatting, java.project.getSettings, java.project.updateSourceAttachment, java.project.resolveWorkspaceSymbol, java.project.upgradeGradle, java.decompile, java.project.createModuleInfo, java.protobuf.generateSources, java.project.resolveSourceAttachment, java.project.addToSourcePath, java.completion.onDidSelect]

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.426
!MESSAGE Started org.eclipse.m2e.core 0ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.802
!MESSAGE ProjectRegistryRefreshJob finished 375ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.886
!MESSAGE Started org.eclipse.buildship.core 83ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2023-05-01 21:12:35.897
!MESSAGE >> initialized

and at "Go-to-definition" time I'm getting the error:

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-05-01 21:13:05.913
!MESSAGE Error getting content via fernflower
!STACK 0
java.nio.file.FileSystemNotFoundException: Provider "jdt" not installed
    at java.base/java.nio.file.Path.of(Path.java:212)
    at java.base/java.nio.file.Paths.get(Paths.java:98)
    at dg.jdt.ls.decompiler.fernflower.BytecodeProvider.loadBytecode(BytecodeProvider.java:55)
    at dg.jdt.ls.decompiler.fernflower.BytecodeProvider.getBytecode(BytecodeProvider.java:46)
    at org.jetbrains.java.decompiler.struct.lazy.LazyLoader.getClassStream(LazyLoader.java:116)
    at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:107)
    at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:63)
    at org.jetbrains.java.decompiler.main.Fernflower.addSource(Fernflower.java:73)
    at org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler.addSource(BaseDecompiler.java:21)
    at dg.jdt.ls.decompiler.fernflower.FernflowerDecompiler.getContent(FernflowerDecompiler.java:81)
    at dg.jdt.ls.decompiler.fernflower.FernflowerDecompiler.decompileContent(FernflowerDecompiler.java:68)
    at dg.jdt.ls.decompiler.common.CachingDecompiler.getContent(CachingDecompiler.java:34)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:110)
    at org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager.getContent(ContentProviderManager.java:81)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$24(JDTLanguageServer.java:898)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Followed by similar errors for all the available providers. I've tried practically everything, recompiled eclipse.jdtls following your ansible scripts, downloaded it from different sources, tried different versions of java. Every time, wiping the data and starting again.

I appreciate this stretches the boundaries of this plugin @mfussenegger, but any pointer here would be super appreciated ❤️ as I'm been going in circles on this. No one else seems to have this error which is always a sign I've forgotten something.

BSteffaniak commented 1 year ago

Just dropping in here to say that I'm also running into this issue. Have you found any solutions to this? I've been following the discussion in the eclipse repo as well.

sledigabel commented 1 year ago

@BSteffaniak thanks for this, I was beginning to think I was the only one with this problem. What is your current config? Are you running on mac?

BSteffaniak commented 1 year ago

Hmm. I've been trying to reproduce this again. I can't seem to get the jdt provider error again. I was getting it on both my macbook as well as my WSL1 Ubuntu instance on my windows pc.

However, I am now getting this error after adding the init_options bundles:

[ERROR][2023-05-25 15:51:09] ...lsp/handlers.lua:535    "May 25, 2023, 3:51:09 PM Failed to load extension bundles 
Load bundle list
org.eclipse.core.runtime.CoreException: Load bundle list
    at org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.loadBundles(BundleUtils.java:169)
    at org.eclipse.jdt.ls.core.internal.handlers.InitHandler.handleInitializationOptions(InitHandler.java:103)
    at org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.initialize(BaseInitHandler.java:64)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.initialize(JDTLanguageServer.java:267)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$1(ParentProcessWatcher.java:144)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
Contains: Cannot extract bundle symbolicName or version /home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.cfr-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.common-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.fernflower-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.procyon-0.0.3.jar
java.nio.file.NoSuchFileException: /home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.cfr-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.common-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.fernflower-0.0.3.jar
/home/bsteffaniak/.local/share/vscode-java-decompiler/server/dg.jdt.ls.decompiler.procyon-0.0.3.jar
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148)
    at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
    at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1264)
    at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
    at java.base/java.util.jar.JarFile.<init>(JarFile.java:347)
    at java.base/java.util.jar.JarFile.<init>(JarFile.java:318)
    at java.base/java.util.jar.JarFile.<init>(JarFile.java:257)
    at org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.getBundleInfo(BundleUtils.java:300)
    at org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.loadBundles(BundleUtils.java:116)
    at org.eclipse.jdt.ls.core.internal.handlers.InitHandler.handleInitializationOptions(InitHandler.java:103)
    at org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.initialize(BaseInitHandler.java:64)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.initialize(JDTLanguageServer.java:267)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$1(ParentProcessWatcher.java:144)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
"

Here is the bulk of my java config. I left out some of the irrelevant parts:

local jdtls_config = {
  on_attach = on_attach,
  cmd = { util.join_paths(home_dir, '.local', 'bin', 'jdtls'), '-data', workspace_dir },
  root_dir = root_dir,
  settings = {
    java = {
      eclipse = {
        downloadSources = true,
      },
      configuration = {
        updateBuildConfiguration = "interactive",
      },
      maven = {
        downloadSources = true,
      },
      implementationsCodeLens = {
        enabled = true,
      },
      referencesCodeLens = {
        enabled = true,
      },
      references = {
        includeDecompiledSources = true,
      },
      format = {
        enabled = true,
        settings = {
          url = vim.fn.stdpath "config" .. "/lang-servers/eclipse-java-google-style.xml",
          profile = "GoogleStyle",
        },
      },
    },
    signatureHelp = { enabled = true },
    completion = {
      favoriteStaticMembers = {
        "org.hamcrest.MatcherAssert.assertThat",
        "org.hamcrest.Matchers.*",
        "org.hamcrest.CoreMatchers.*",
        "org.junit.jupiter.api.Assertions.*",
        "java.util.Objects.requireNonNull",
        "java.util.Objects.requireNonNullElse",
        "org.mockito.Mockito.*",
      },
    },
    contentProvider = { preferred = "fernflower" },
    extendedClientCapabilities = extendedClientCapabilities,
    sources = {
      organizeImports = {
        starThreshold = 9999,
        staticStarThreshold = 9999,
      },
    },
    codeGeneration = {
      toString = {
        template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
      },
      useBlocks = true,
    },
  },

  flags = {
    allow_incremental_sync = true,
  },
  init_options = {
    bundles = {
      vim.fn.glob(home_dir .. "/.local/share/vscode-java-decompiler/server/*.jar"),
    },
  },
}

jdtls.start_or_attach(jdtls_config)

It was mostly modeled after this post https://alpha2phi.medium.com/neovim-for-beginners-java-6a86cf1a91a5

mfussenegger commented 1 year ago

Closing this here in favour of https://github.com/eclipse/eclipse.jdt.ls/issues/2644

sledigabel commented 1 year ago

@mfussenegger I've JUST found out what was causing the problem (still don't know why). I'm using lspsaga to add some nice decorations and features around the LSP jumps. Somehow when loading the lspsaga plugin (and using the lspsaga go to definition or the builtin function) the call fails.

I'll dig this up see if I can find why. In the meantime, thank you for your help on this 🙇

BSteffaniak commented 1 year ago

Yep, that was my issue too. I've been wanting to kick lspsaga for a while. This gave me the motivation to do so. Thanks!