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

error when hovering on java file that is not on main projects build path #317

Open
maxandersen opened this issue Oct 29, 2024 · 19 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@maxandersen
Copy link

microprofile is failing/erroring when i'm hovering on elements on a java file (using jbang):

[Error - 06:06:53] Request textDocument/hover failed.
  Message: Request microprofile/java/hover failed with message: jbang-joke-bot [in quarkus-langchain4j-samples-parent] is not on its project's build path
  Code: -32603 

probably missing a try/catch as it shouldn't block hovering.

@maxandersen
Copy link
Author

for now i've uninstalled microprofile/quarkus tooling as it otherwise kept happening :/

@angelozerr
Copy link
Contributor

could you share your project please.

@angelozerr
Copy link
Contributor

@maxandersen could you please share your project, thanks!

@maxandersen
Copy link
Author

https://github.com/quarkiverse/quarkus-langchain4j/tree/main/samples/jbang-joke-bot

probably I had the whole repo checked out and then opened cursor or vscode in the samples directory.

@angelozerr
Copy link
Contributor

@angelozerr
Copy link
Contributor

@rgrunber @datho7561 could you try the issue please, I cannot reproduce it. Thanks!

@angelozerr
Copy link
Contributor

@angelozerr
Copy link
Contributor

angelozerr commented Nov 4, 2024

@maxandersen if you can reproduce it, it would be very nice to have the stack trace of the error by using Java: Open All Log Files

@angelozerr angelozerr added the bug Something isn't working label Nov 4, 2024
@maxandersen
Copy link
Author

i can try - i just uninstalled microprofile again as hit me again.

@maxandersen
Copy link
Author

installed microprofile/quarkus tools again and its using 0.13 - lets see if pops up again

@maxandersen
Copy link
Author

is there potential a log somewhere I can find the old errors?

@angelozerr
Copy link
Contributor

is there potential a log somewhere I can find the old errors?

@fbricon @datho7561 @rgrunber do you know if it is possible?

@fbricon
Copy link
Collaborator

fbricon commented Nov 7, 2024

if you didn't clean the workspace, you can find the old JDT logs still from Java: Open All Log Files. If log rolling happened, you'd need to look into the directory containing the jdt.ls log to find older files.

@angelozerr
Copy link
Contributor

@maxandersen as you said I think we need to do some try / catch but without some stacktraces it is difficult to know where we need to do that.

@maxandersen
Copy link
Author

I searched all .log files in ~/Library/Application Support with find . -name "*.log" -exec grep -H "hover failed" '{}' + and found nothing :/

which is weird as it happened multiple times at different occasions - could it be not logging ?

@angelozerr
Copy link
Contributor

Ok could you add in your settings.json "microprofile.tools.trace.server": "verbose" to LSP console and share with us the trace please.

@rgrunber
Copy link
Member

rgrunber commented Nov 8, 2024

Would be good to also add "java.trace.server": "verbose" so that any interaction in the microprofile JDT extension components also gets more info.

@angelozerr
Copy link
Contributor

@maxandersen I wonder how you have excluded your Java class from classpath?

I want to create a release of vscode-quarkus ASAP with Roq support and I think it would be nice to fix your issue also.

Please share your logs.

@angelozerr angelozerr self-assigned this Nov 20, 2024
@angelozerr angelozerr moved this to Todo in Java Tooling Nov 20, 2024
@rgrunber
Copy link
Member

rgrunber commented Nov 25, 2024

Tried with vscode-java, vscode-microprofile, vscode-quarkus, vscode-jbang pre-release builds. Haven't reproduce the hover failure though.

  • If I load the full project at the root, everything seems to work except that the samples/ project isn't even part of the modules list, so nothing in there will ever be detected once vscode-java treats it as a Maven project.
  • If I load the project at the samples/ folder then I get the following error :
stacktrace
Nov 25, 2024 12:36:19 P.M. org.eclipse.lsp4mp.jdt.core.utils.JDTMicroProfileUtils isMicroProfileProject
INFO: Current Java project is not a MicroProfile project
Java Model Exception: Error in Java Model (code 969): quarkus-langchain4j-samples-parent does not exist
	at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:556)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:234)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:569)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:292)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:278)
	at org.eclipse.jdt.internal.core.JavaProject.getJavaProjectElementInfo(JavaProject.java:2040)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2775)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2769)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2787)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2779)
	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1681)
	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1582)
	at org.eclipse.lsp4mp.jdt.core.utils.JDTMicroProfileUtils.isMicroProfileProject(JDTMicroProfileUtils.java:149)
	at org.eclipse.lsp4mp.jdt.internal.core.providers.MicroProfileProjectLabelProvider.getProjectLabels(MicroProfileProjectLabelProvider.java:37)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelDefinition.getProjectLabels(ProjectLabelDefinition.java:44)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabels(ProjectLabelManager.java:137)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabelInfo(ProjectLabelManager.java:79)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabelInfo(ProjectLabelManager.java:99)
	at org.eclipse.lsp4mp.jdt.internal.core.ls.JavaProjectDelegateCommandHandler.getProjectLabelInfo(JavaProjectDelegateCommandHandler.java:68)
	at org.eclipse.lsp4mp.jdt.internal.core.ls.JavaProjectDelegateCommandHandler.executeCommand(JavaProjectDelegateCommandHandler.java:43)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:610)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:690)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:527)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

Nov 25, 2024 12:36:19 P.M. com.redhat.microprofile.jdt.quarkus.JDTQuarkusUtils isQuarkusProject
INFO: Current Java project is not a Quarkus project
Java Model Exception: Error in Java Model (code 969): quarkus-langchain4j-samples-parent does not exist
	at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:556)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:234)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:569)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:292)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:278)
	at org.eclipse.jdt.internal.core.JavaProject.getJavaProjectElementInfo(JavaProject.java:2040)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2775)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2769)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2787)
	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2779)
	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1681)
	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1582)
	at com.redhat.microprofile.jdt.quarkus.JDTQuarkusUtils.isQuarkusProject(JDTQuarkusUtils.java:82)
	at com.redhat.microprofile.jdt.internal.quarkus.providers.QuarkusProjectLabelProvider.getProjectLabels(QuarkusProjectLabelProvider.java:34)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelDefinition.getProjectLabels(ProjectLabelDefinition.java:44)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabels(ProjectLabelManager.java:137)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabelInfo(ProjectLabelManager.java:79)
	at org.eclipse.lsp4mp.jdt.core.ProjectLabelManager.getProjectLabelInfo(ProjectLabelManager.java:99)
	at org.eclipse.lsp4mp.jdt.internal.core.ls.JavaProjectDelegateCommandHandler.getProjectLabelInfo(JavaProjectDelegateCommandHandler.java:68)
	at org.eclipse.lsp4mp.jdt.internal.core.ls.JavaProjectDelegateCommandHandler.executeCommand(JavaProjectDelegateCommandHandler.java:43)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:610)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:690)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:527)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

I'm guessing to detect this as a Quarkus project, you need the root. Despite that, it looks like most of the projects that declare a pom file do seem to load correctly and language support works. However, jbang-joke-bot is not on the modules list for the samples/ sub-project. However just comes back empty.

  • If I load the project at the jbang-joke-bot folder, things seem to work well. Everything appears to load, and hover works for me. I did notice this error :
stacktrace
[Error - 12:29:28] Nov 25, 2024, 12:29:28 p.m. Failed to read package name from file:/home/rgrunber/.config/Code/User/workspaceStorage/e8db30260e25fca9422d884683ad0a8c/redhat.java/jdt_ws/jokes.java/
Is a directory
java.io.IOException: Is a directory
	at java.base/sun.nio.ch.UnixFileDispatcherImpl.read0(Native Method)
	at java.base/sun.nio.ch.UnixFileDispatcherImpl.read(UnixFileDispatcherImpl.java:51)
	at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:341)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:307)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:284)
	at java.base/sun.nio.ch.FileChannelImpl.implRead(FileChannelImpl.java:251)
	at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:231)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:74)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
	at java.base/java.nio.file.Files.read(Files.java:3248)
	at java.base/java.nio.file.Files.readAllBytes(Files.java:3299)
	at java.base/java.nio.file.Files.readString(Files.java:3370)
	at java.base/java.nio.file.Files.readString(Files.java:3329)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.getPackageName(JDTUtils.java:341)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.getFakeCompilationUnit(JDTUtils.java:305)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveCompilationUnit(JDTUtils.java:201)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:489)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.resolveTypeRoot(JDTUtils.java:448)
	at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getJavaProjectFromUri(ProjectCommand.java:538)
	at org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getClasspaths(ProjectCommand.java:414)
	at org.eclipse.jdt.ls.core.internal.JDTDelegateCommandHandler.executeCommand(JDTDelegateCommandHandler.java:101)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:610)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:690)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:527)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)

Basically, some "client" is calling JDT-LS with :

ExecuteCommandParams [
  workDoneToken = null
  command = "java.project.getClasspaths"
  arguments = ArrayList (
    "file:/home/rgrunber/.config/Code/User/workspaceStorage/e8db30260e25fca9422d884683ad0a8c/redhat.java/jdt_ws/jokes.java/",
    "{\"scope\":\"test\"}"
  )
]

Might be irrelevant though, given that it does seem to work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

4 participants