Plugin tries to cast a PsiJavaFileImpl into a XmlFile
Answered
Hi guys. I'm working on a plugin for the OFBiz ERP. Currently, i'm working on the references from a java file to a Service definition wich is in a XML file.
And i get this error :
2021-07-30 18:26:07,065 [ 153128] ERROR - aemon.impl.PassExecutorService - class com.intellij.psi.impl.source.PsiJavaFileImpl cannot be cast to class com.intellij.psi.xml.XmlFile (com.intellij.psi.impl.source.PsiJavaFileImpl is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @7930fb8a; com.intellij.psi.xml.XmlFile is in unnamed module of loader com.intellij.util.lang.UrlClassLoader @6d8a00e3)
java.lang.ClassCastException: class com.intellij.psi.impl.source.PsiJavaFileImpl cannot be cast to class com.intellij.psi.xml.XmlFile (com.intellij.psi.impl.source.PsiJavaFileImpl is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @7930fb8a; com.intellij.psi.xml.XmlFile is in unnamed module of loader com.intellij.util.lang.UrlClassLoader @6d8a00e3)
at org.apache.ofbiz.dom.editor.context.OfbizControllerContext.isInContext(OfbizControllerContext.java:24)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.getDirectlyApplicableContextTypes(TemplateManagerImpl.java:515)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.getApplicableContextTypes(TemplateManagerImpl.java:649)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.isApplicable(TemplateManagerImpl.java:564)
at com.intellij.codeInsight.template.impl.TemplateManagerImpl.isApplicable(TemplateManagerImpl.java:560)
at com.intellij.codeInsight.daemon.impl.quickfix.IterateOverIterableIntention.isAvailable(IterateOverIterableIntention.java:61)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.availableFor(ShowIntentionActionsHandler.java:157)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.lambda$getActionsToShow$1(ShowIntentionsPass.java:322)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseBetweenHostAndInjected(ShowIntentionActionsHandler.java:190)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:321)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:226)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:54)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:399)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1110)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:392)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:629)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:581)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:391)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:367)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:170)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:182)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:365)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:181)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
2021-07-30 18:26:07,067 [ 153130] ERROR - aemon.impl.PassExecutorService - IntelliJ IDEA 2020.2.4 Build #IC-202.8194.7
2021-07-30 18:26:07,067 [ 153130] ERROR - aemon.impl.PassExecutorService - JDK: 11.0.9; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2021-07-30 18:26:07,067 [ 153130] ERROR - aemon.impl.PassExecutorService - OS: Linux
2021-07-30 18:26:07,067 [ 153130] ERROR - aemon.impl.PassExecutorService - Plugin to blame: OFBiz IDEA Integration version: 0.10.1
2021-07-30 18:26:07,068 [ 153131] ERROR - aemon.impl.PassExecutorService - Last Action: GotoDeclaration
Does it seems familiar to someone ? As far as i understand, there is an unsuccessful cast, bit i don't know why the cast is tried in a first place.
Is there some code i can share ? The project is quite large, i don't know witch part to share to get any help.
Thanks beforehand
Please sign in to leave a comment.
Please link sources of
Sorry for late answer, we've started fresh on a new structure, but the problem remains.
We dit it in groovy this time, and i got the same cast error with component file.
Here is the file description :
and here is the dom description :
And here is the error :
it seems that the type returned by the DomManager is DomFileElementImpl, but that's not what i want. How do i convert it ?
interface ComponentFile extends DomFileElement
it should extend DomElement as it is the root DomElement
It worked, thanks a lot !