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

InvocationTargetException caused by "Add as Maven Project" #149

Open TrevCraw opened 1 year ago

TrevCraw commented 1 year ago

When in the state that causes https://github.com/OpenLiberty/liberty-tools-intellij/issues/132 - corrupted/old .idea directory, IntelliJ does not recognize Maven projects. You can right click on the pom.xml and select "Add as Maven Project", then IntelliJ will recognize the project as a Maven project. One time attempting this, the following exception occurred:

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: com.intellij.diagnostic.PluginException: Element: class com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl #JAVA  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/Users/TREVORCrawford/Git/guide-reactive-rest-client/finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java, vFileId=157667, content=VirtualFileContent{size=2643}, eventSystemEnabled=true}(c946414); com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/Users/TREVORCrawford/Git/guide-reactive-rest-client/finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java, vFileId=157667, content=VirtualFileContent{size=2643}, eventSystemEnabled=true}(52c8b46)
invalidated at: see attachment [Plugin: com.intellij.java]
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:92)
    at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:483)
    at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.getKindEnum(PsiJavaCodeReferenceElementImpl.java:92)
    at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.getCanonicalText(PsiJavaCodeReferenceElementImpl.java:289)
    at com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.getCanonicalText(PsiJavaCodeReferenceElementImpl.java:278)
    at com.intellij.psi.impl.source.tree.java.PsiAnnotationImpl.getQualifiedName(PsiAnnotationImpl.java:77)
    at io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.servlet.ServletDiagnosticsCollector.collectDiagnostics(ServletDiagnosticsCollector.java:61)
    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
Caused by: com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl #JAVA  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/Users/TREVORCrawford/Git/guide-reactive-rest-client/finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java, vFileId=157667, content=VirtualFileContent{size=2643}, eventSystemEnabled=true}(c946414); com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/Users/TREVORCrawford/Git/guide-reactive-rest-client/finish/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java, vFileId=157667, content=VirtualFileContent{size=2643}, eventSystemEnabled=true}(52c8b46)
invalidated at: see attachment
    ... 31 more
turkeylurkey commented 1 year ago

Not able to reproduce. I started with a new project which does not have a pom.xml. Then added pom.xml and right clicked on the pom.xml and selected "Add as Maven Project".