OpenLiberty / liberty-tools-intellij

IntelliJ IDEA extension for Liberty
https://plugins.jetbrains.com/plugin/14856-open-liberty-tools
Eclipse Public License 2.0
13 stars 26 forks source link

MP/Jakarta features broken on Windows for old IntelliJ projects #132

Open evie-lau opened 2 years ago

evie-lau commented 2 years ago

This seems to happen in both ls-integration, and the recently working java17 version of the branch.

Specifically...

NOTE: when installing the plugin zip, activating MP/Jakarta LS features seems to work fine without issues.

Nov 10, 2022 4:15:55 PM org.eclipse.lsp4jakarta.JakartaTextDocumentService hover
INFO: received textDocument/hover request
2022-11-10 16:15:55,470 [  31426] SEVERE - o.e.l.j.RemoteEndpoint - Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    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 io.openliberty.tools.intellij.lsp4mp.lsp4ij.LanguageServerWrapper.lambda$start$0(LanguageServerWrapper.java:245)
    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)
Caused by: java.lang.reflect.InvocationTargetException
    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)
    ... 12 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.intellij.psi.PsiPackage.getAnnotations()" because "psiPackage" is null
    at io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.annotations.AnnotationDiagnosticsCollector.collectDiagnostics(AnnotationDiagnosticsCollector.java:71)
    at io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.PropertiesManagerForJakarta.lambda$collectDiagnostics$2(PropertiesManagerForJakarta.java:112)
    at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$1(DumbService.java:157)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:941)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:68)
    at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:150)
    at io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.PropertiesManagerForJakarta.collectDiagnostics(PropertiesManagerForJakarta.java:109)
    at io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.PropertiesManagerForJakarta.diagnostics(PropertiesManagerForJakarta.java:95)
    at io.openliberty.tools.intellij.lsp4jakarta.lsp.JakartaLanguageClient.getJavaDiagnostics(JakartaLanguageClient.java:77)
    ... 17 more
Nov 10, 2022 4:15:55 PM org.eclipse.lsp4jakarta.JakartaTextDocumentService lambda$triggerValidationFor$6
SEVERE: Return LSP4Jakarta getJavaDiagnostics() from client did not succeed: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
Caused by: java.lang.reflect.InvocationTargetException

Caused by: java.lang.NullPointerException: Cannot invoke "com.intellij.psi.PsiPackage.getAnnotations()" because "psiPackage" is null
evie-lau commented 2 years ago

While messing around with environment testing, I somehow got this to work properly even with the same conditions outlined before. May need more investigation

TrevCraw commented 2 years ago

Also seeing this issue with a Gradle project (running runIde on Windows) - https://github.com/openliberty/guide-gradle-intro A second exception I'm seeing while attempting hover and completion is below:

Details: Current thread: Thread[JobScheduler FJ pool 0/11,4,main] 1360345111
Dispatch thread: false; isDispatchThread(): false
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1558623442

java.lang.Throwable: Read access is allowed from inside read-action (or EDT) only (see com.intellij.openapi.application.Application.runReadAction())
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
    at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1056)
    at com.intellij.psi.impl.source.tree.TreeElement.assertReadAccessAllowed(TreeElement.java:424)
    at com.intellij.psi.impl.source.tree.SharedImplUtil.findFileElement(SharedImplUtil.java:79)
    at com.intellij.psi.impl.source.tree.SharedImplUtil.getContainingFile(SharedImplUtil.java:54)
    at com.intellij.psi.impl.source.SubstrateRef$2.getContainingFile(SubstrateRef.java:100)
    at com.intellij.extapi.psi.StubBasedPsiElementBase.getContainingFile(StubBasedPsiElementBase.java:239)
    at com.intellij.extapi.psi.StubBasedPsiElementBase.getProject(StubBasedPsiElementBase.java:276)
    at io.openliberty.tools.intellij.lsp4mp.lsp4ij.operations.hover.LSPTextHover.lambda$initiateHoverRequest$5(LSPTextHover.java:213)
    at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
    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)
TrevCraw commented 2 years ago

Also seeing the InvocationTargetException when importing the plugin as a zip file outside the runIde environment.

turkeylurkey commented 1 year ago

because "psiPackage" is null exception is fixed. Exception related to hover is separate.

TrevCraw commented 1 year ago

It appears that this issue may be caused by .idea directories leftover from old versions of IntelliJ. One workaround is to delete the .idea directory and restart IntelliJ. Another, better workaround is to right-click on the pom.xml or build.gradle of the afflicted project and select "Add as Maven project" or "Add as Gradle project".

In one case, "Add as Maven project" did result in an exception (issue here: https://github.com/OpenLiberty/liberty-tools-intellij/issues/149), however, the issues reported here were resolved and MP/Jakarta language features were still enabled.

TrevCraw commented 1 year ago

Example of an .idea directory that is causing the behaviour reported in this issue. idea.zip