NoClassDefFoundError with "psiMethod"
已回答
I was trying to use the "psi demo example" in github in my plugin
It compiles, ok but when executing I have :
2020-07-24 18:08:16,338 [ 11440] ERROR - llij.ide.plugins.PluginManager - com/intellij/psi/PsiMethod
java.lang.NoClassDefFoundError: com/intellij/psi/PsiMethod
I'm using Intellij ultimate 2020.1 (Build #IU-201.8743.12)
Any clues ?
请先登录再写评论。
I have the same problem with "PsiClass" or "PsiClassImpl" or "PsiMethodImpl"
But "PsiNamedElement" or "PsiNameIdentifierOwner" works ok
For the PsiClass, if in the debugger I do "vPsiClass.getClass()", I will have :
"com.intellij.lang.ecmascript6.psi.impl.ES6ClassImpl"
I tried to "import it", but com.intellij.lang doesn't have a "ecmascript6" ???
Do you have the following dependency set in your plugin.xml?
My "depends" entry was
So I changed to the one you suggested. Now my code execute correctly, but it doesn"t find any "current method" or "current class", I'm using ES6 JavaScript
ES6ClassImpl is available in the JavaScript plugin. You have to add the dependency to the JavaScript plugin both in your Gradle and plugin.xml. Keep in mind, that it's available in IntelliJ Ultimate only:
intellij {type = "IU"
setPlugins("JavaScript")
}
Sorry but how to I add
to my plugin.xml ?
For Gradle i'm not using it
The above snippet should be applied to the Gradle configuration.
What about plugin.xml ?
As mentioned above - dependency is called JavaScript for both.
Is there a way to know if a PsiElement is a method without depending on other plugins? i want a general isMethod or something that will catch all languages, or at least the languages that have methods/functions like java ,python etc.
read this
https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
I'm good after do this.
How can I determine if a PsiElement corresponds to a method, without using any plugin-specific APIs?
drift boss
I ran into the same issue before — updating the IntelliJ SDK and re-importing the dependencies fixed the
psiMethoderror for me.This error usually means an IntelliJ SDK mismatch.
PsiMethodisn’t found at runtime because the plugin was built against a different IDE version or missing PSI dependencies.Check
sinceBuild / untilBuild, align the IntelliJ Platform version, and make sure PSI is included.This error usually points to a missing or incompatible dependency at runtime. If
psiMethodis involved, it’s worth double-checking the IntelliJ platform or plugin SDK versions to make sure they match the IDE you’re running. Cleaning the build and re-syncing dependencies can also help narrow down the cause.This error explanation is really helpful. I’ve run into NoClassDefFoundError with psiMethod when working on IntelliJ plugins, and the classpath mismatch insight makes a lot of sense. Thanks for breaking it down clearly.
Good write-up! The part about dependency versions and IDE SDK compatibility helped me spot the issue in my setup. I didn’t realize psiMethod could fail just because of an outdated IntelliJ platform.
Thanks for sharing this. The explanation about how psiMethod gets loaded at runtime really helped me understand why the NoClassDefFoundError happens in some environments but not others.
This post saved me a lot of time. I was chasing the wrong cause until I realized the issue was related to IntelliJ SDK and missing classes like psiMethod. Very useful breakdown.
Errors like this often happen when an IntelliJ/IDEA PSI class isn’t available at runtime even though it compiled fine. Double-checking plugin or SDK versions helps a lot. Randomly, I relax between fixes by browsing drawing ideas
I’ve seen this when Gradle builds fine but the IDE runtime doesn’t include certain platform libraries. Re-importing the project and rebuilding can sometimes fix it.
Could be a classloader issue, especially in plugin development. Make sure the required IntelliJ modules are declared in your plugin configuration.
If you recently updated the IDE or SDK, some internal APIs might have moved or changed. Invalidating caches and restarting the IDE is worth trying.
Check your dependency tree for exclusions. Sometimes a transitive dependency containing PSI classes gets excluded without you noticing.
This kind of
NoClassDefFoundErrorusually points to a missing dependency at runtime rather than a compilation issue. In IntelliJ plugin development, classes likePsiMethodbelong to specific modules (likejava), so if your plugin doesn’t declare the proper dependency inplugin.xml(e.g.,<depends>com.intellij.modules.java</depends>), you’ll hit exactly this error. Visualizing dependency trees can get messy—tools like Nano AI could actually help map these relationships more clearly.Overall, the fix is usually straightforward: add the correct module dependency (especially
com.intellij.modules.java) and ensure your SDK includes Java support. Once that’s done, the error should disappear. It’s like getting past an early obstacle in slope unblocked—once configured correctly, everything flows smoothly.Given that the code compiles but fails at runtime, it strongly suggests your SDK setup or plugin configuration is incomplete. The PSI APIs are not always included by default depending on your target platform. It’s similar to how using something like lyrics to song AI requires the right input context—without the proper setup, the output just won’t work as expected.
Another thing to check is whether your plugin is targeting the correct IntelliJ platform (IDEA vs. other JetBrains IDEs). Some IDEs don’t bundle Java PSI მხარდაჭერა unless explicitly added. It’s a bit like running a game such as speed stars—if the environment isn’t right, even simple actions fail.
Also make sure your Gradle (if you’re using it) includes the correct IntelliJ plugin configuration, like
intellij { plugins = ['java'] }. Without that, the runtime won’t have access toPsiMethod. It’s comparable to missing core mechanics in something like baseball bros—the structure is there, but key components are absent.The official PSI demo assumes you’re working within a properly configured IntelliJ SDK environment. If you copied the code into a different setup, it may not bring all required modules with it. This kind of mismatch is similar to logic gaps you might see in puzzle flows like blockblast online, where one missing piece breaks the whole chain.
Double-check your
plugin.xmland ensure dependencies are declared correctly. This is often overlooked but critical. Think of it like setting up rules before starting a match in basketball game—without the right setup, nothing runs properly.