eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
typeDefinition for files not loaded throws error
started the jdt as in the README andi initialized it , most things seem to work.
When doing a typedefinition request I am getting this error:
{'code': -32603, 'message': 'Internal error.', 'data': 'java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.NavigateToTypeDefinitionHandler.computeTypeDefinitionNavigation(NavigateToTypeDefinitionHandler.java:88)\n\tat org.eclipse.jdt.ls.core.internal.handlers.NavigateToTypeDefinitionHandler.typeDefinition(NavigateToTypeDefinitionHandler.java:56)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$10(JDTLanguageServer.java:616)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n'}
This happens when the type requested is a class from another file, When doing a symbols request on the other file first and then doing the same typeDefinition request, it returns with correct values and no exception is thrown.
Is it possible to provide more detailed steps or a sample project?
I tried to trigger a type definition from a class file but didn't observe such NPE.
The project I used - https://github.com/grozateofil/RomaniaInvestmentBank JDT command line - 'java', '-Xmx2G', '-noverify', '-Declipse.application=org.eclipse.jdt.ls.core.id1', '-Dosgi.bundles.defaultStartLevel=4', '-Declipse.product=org.eclipse.jdt.ls.core.product', '-Dlog.protocol=true', '-Dlog.level=ALL', '-jar', 'plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar', '-configuration', './config_linux', '-data', '/data/code_folder', '--add-modules=ALL-SYSTEM', '--add-opens java.base/java.util=ALL-UNNAMED', '--add-opens java.base/java.lang=ALL-UNNAMED'
I initialize with the following capabilities:
capabilities = { "textDocument": { "codeAction": {"dynamicRegistration": True}, "codeLens": {"dynamicRegistration": True}, "colorProvider": {"dynamicRegistration": False}, "completion": { "completionItem": { "commitCharactersSupport": False, "documentationFormat": ["markdown", "plaintext"], "snippetSupport": True, }, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ] }, "contextSupport": True, "dynamicRegistration": True, }, "definition": {"dynamicRegistration": True}, "documentHighlight": {"dynamicRegistration": True}, "documentLink": {"dynamicRegistration": True}, "documentSymbol": { "dynamicRegistration": True, "hierarchicalDocumentSymbolSupport": True, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, ] }, }, "formatting": {"dynamicRegistration": False}, "hover": { "contentFormat": ["markdown", "plaintext"], "dynamicRegistration": False, }, "implementation": {"dynamicRegistration": True}, "onTypeFormatting": {"dynamicRegistration": False}, "publishDiagnostics": {"relatedInformation": True}, "rangeFormatting": {"dynamicRegistration": False}, "references": {"dynamicRegistration": True}, "rename": {"dynamicRegistration": False}, "signatureHelp": { "dynamicRegistration": False, "signatureInformation": {"documentationFormat": ["markdown", "plaintext"]}, }, "synchronization": { "didSave": True, "dynamicRegistration": False, "willSave": True, "willSaveWaitUntil": True, }, "typeDefinition": {"dynamicRegistration": True, "linkSupport": False}, }, "workspace": { "applyEdit": True, "configuration": True, "didChangeConfiguration": {"dynamicRegistration": False}, "didChangeWatchedFiles": {"dynamicRegistration": False}, "executeCommand": {"dynamicRegistration": False}, "symbol": { "dynamicRegistration": True, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, ] }, }, "workspaceEdit": {"documentChanges": True}, "workspaceFolders": True, }, }
then, after symbols request to the file I am doing the following request: [ this is the line: private Session session = HibernateUtils.getSessionFactory().getCurrentSession(); ]
DEBUG sending textDocument/typeDefinition with args {'textDocument': file://data/code_folder/src/rib/dao/AddressDao.java, 'position': line 12 c:17} and 131 to lsp DEBUG src.code_scan_lsp.lsp_services.lsp_wrapper:lsp_wrapper.py:23 window/logMessage ({'type': 3, 'message': '26 Jun 2022, 10:23:52 >> document/typeDefinition'},) WARNING src.code_scan_lsp.lsp_client.lsp_endpoint:lsp_endpoint.py:128 Seen error from LSP - {'code': -32603, 'message': 'Internal error.', 'data': 'java.util.concurrent.CompletionException: java.lang.NullPointerException\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\nCaused by: java.lang.NullPointerException\n\tat org.eclipse.jdt.ls.core.internal.handlers.NavigateToTypeDefinitionHandler.computeTypeDefinitionNavigation(NavigateToTypeDefinitionHandler.java:88)\n\tat org.eclipse.jdt.ls.core.internal.handlers.NavigateToTypeDefinitionHandler.typeDefinition(NavigateToTypeDefinitionHandler.java:56)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$10(JDTLanguageServer.java:616)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 6 more\n'}
@yuval-piiano I can't reproduce the issue in VS Code Java. Could you try to initialize the server with
"rootPath": "<path_to_RomaniaInvestmentBank>",
"rootUri": "file://<path_to_RomaniaInvestmentBank>",
"capabilities": {
...
}
and attach your /data/code_folder/.metadata/.log?
client.log metadata.log Attaching metadata.log from the .metadata folder and my client log (which tracks all lsp requests, the typeDefinition errors are logged as WARNING)