JDTLS' code action/completion suggests really out of place things

I'm trying to use Neovim whenever I can, partly to learn it and partly because I just prefer it (when it works). One big annoying problem I run into constantly is the suggestions sometimes just breaks and suggests things like Listfrom org.hibernate instead of java.util. The fix is rather simple, just relaunch Neovim (just restarting the LSP sometimes works, but faster and more reliable to just quit it completely), but when I work on something new I may not notice that it happened again and I assume the autofill is correct. From what I've seen, other people have had similar experience with JDTLS on other editors so I don't think this is an LSP/neovim config problem (since it does work nicely otherwise, even better than intellij in some rare cases). None of the fixes I've seen (change jdk version, deleting JDTLS cache, etc.) works. I also tried using some Java-specific plugins for neovim but saw no or worse effect.
No description
No description
11 Replies
JavaBot
JavaBot4mo ago
This post has been reserved for your question.
Hey @aquaduck97! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st4mo ago
I think you can configure type filters that prevent some types from being shown (at least that's possible with JDT)? Also are there any logs?
aquaduck97
aquaduck97OP4mo ago
I get this a bunch: java.io.FileNotFoundException: /home/tux/.cache/jdtls/workspace/.metadata/.plugins/org.eclipse.jdt.core/2534747095.index
\tat java.base/java.io.FileInputStream.open0(Native Method)\n
\tat java.base/java.io.FileInputStream.open(FileInputStream.java:185)\n
\tat java.base/java.io.FileInputStream.<init>(FileInputStream.java:139)\n
\tat org.eclipse.jdt.internal.core.index.FileIndexLocation.getInputStream(FileIndexLocation.java:83)\n
\tat org.eclipse.jdt.internal.core.index.DiskIndex.readAllDocumentNames(DiskIndex.java:633)\n
\tat org.eclipse.jdt.internal.core.index.DiskIndex.mergeWith(DiskIndex.java:536)\n
\tat org.eclipse.jdt.internal.core.index.Index.save(Index.java:229)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndex(IndexManager.java:1135)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndexes(IndexManager.java:1178)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.notifyIdle(IndexManager.java:822)\n
\tat org.eclipse.jdt.internal.core.search.processing.JobManager.indexerLoop(JobManager.java:508)\n
\tat java.base/java.lang.Thread.run(Thread.java:1447)\n"
\tat java.base/java.io.FileInputStream.open0(Native Method)\n
\tat java.base/java.io.FileInputStream.open(FileInputStream.java:185)\n
\tat java.base/java.io.FileInputStream.<init>(FileInputStream.java:139)\n
\tat org.eclipse.jdt.internal.core.index.FileIndexLocation.getInputStream(FileIndexLocation.java:83)\n
\tat org.eclipse.jdt.internal.core.index.DiskIndex.readAllDocumentNames(DiskIndex.java:633)\n
\tat org.eclipse.jdt.internal.core.index.DiskIndex.mergeWith(DiskIndex.java:536)\n
\tat org.eclipse.jdt.internal.core.index.Index.save(Index.java:229)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndex(IndexManager.java:1135)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.saveIndexes(IndexManager.java:1178)\n
\tat org.eclipse.jdt.internal.core.search.indexing.IndexManager.notifyIdle(IndexManager.java:822)\n
\tat org.eclipse.jdt.internal.core.search.processing.JobManager.indexerLoop(JobManager.java:508)\n
\tat java.base/java.lang.Thread.run(Thread.java:1447)\n"
(part of the same error) And then this:
[ERROR][2025-09-02 16:25:17] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "WARNING: Using incubator modules: jdk.incubator.vector\n"
[ERROR][2025-09-02 16:25:18] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "sep. 02, 2025 4:25:17 EM org.apache.aries.spifly.BaseActivator log\nINFO: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic\n"
[WARN][2025-09-02 16:25:19] ...lsp/handlers.lua:564 "2 sep. 2025 16:25:18 The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.\nnull"
[ERROR][2025-09-02 16:25:19] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "WARNING: A terminally deprecated method in sun.misc.Unsafe has been called\nWARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/home/tux/.cache/jdtls/config/org.eclipse.osgi/68/0/.cp/jars/guice-5.1.0.jar)\nWARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner\nWARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release\n"
[WARN][2025-09-02 16:25:20] ...m/lsp/client.lua:875 "The language server jdtls triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2025-09-02 16:25:17] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "WARNING: Using incubator modules: jdk.incubator.vector\n"
[ERROR][2025-09-02 16:25:18] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "sep. 02, 2025 4:25:17 EM org.apache.aries.spifly.BaseActivator log\nINFO: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic\n"
[WARN][2025-09-02 16:25:19] ...lsp/handlers.lua:564 "2 sep. 2025 16:25:18 The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.\nnull"
[ERROR][2025-09-02 16:25:19] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "WARNING: A terminally deprecated method in sun.misc.Unsafe has been called\nWARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/home/tux/.cache/jdtls/config/org.eclipse.osgi/68/0/.cp/jars/guice-5.1.0.jar)\nWARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner\nWARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release\n"
[WARN][2025-09-02 16:25:20] ...m/lsp/client.lua:875 "The language server jdtls triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless"
dan1st
dan1st4mo ago
that is when it starts I think and the WARNING: Using incubator modules: jdk.incubator.vector is probably because of the --add-modules=ALL_SYSTEM or something like that but it shouldn't cause issues normally Does that happen when you call the content assist which misses java.util.List or does it happen on startup? that error is likely related to the issue
aquaduck97
aquaduck97OP4mo ago
It's seemingly random, it's with both the completion as I type and the code actions popup. I haven't found any way to replicate it, it just happens
dan1st
dan1st4mo ago
Does renaming the .metadata directory change anything? I would rather rename it rather than deleting it just in case ;) Note: This may get rid of your settings
aquaduck97
aquaduck97OP4mo ago
Maybe it loads faster now ( could sometimes take a few seconds to load, though that also seemed random) Completion is there so nothing broke what I can see at least
dan1st
dan1st4mo ago
Did it recreate the .index files?
aquaduck97
aquaduck97OP4mo ago
Yep
No description
aquaduck97
aquaduck97OP4mo ago
I cleared the lsp.log file and hopped in a java file and made a change and got some clearer view of the errors. Couldn't find a paste service that either didn't cost money, didn't require an account or blocked random words though so this was the best I could find, bit annoying to use tbh: https://voidbin.com/paste/247b4ce5-d54f-42c8-bb8d-993a0ce1bce9
Untitled Paste
[START][2025-09-02 16:59:46] LSP logging initiated [ERROR][2025-09-02 16:59:46] ...p/_transport.lua:36 "rpc" "jdtls" "stderr" "WARNING: Using incubato
JavaBot
JavaBot4mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?