ClassCastException due to PluginClassLoader

Answered

I am developing a plugin and am encountering some weird behavior. I am getting the following error:

java.lang.ClassCastException: class javax.swing.tree.DefaultMutableTreeNode cannot be cast to class io.notestash.evernote.ui.view.EvernoteNoteTreeNode (javax.swing.tree.DefaultMutableTreeNode is in module java.desktop of loader 'bootstrap'; io.notestash.evernote.ui.view.EvernoteNoteTreeNode is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @6a7aa018)

I am not sure what this error is indicating or how to go about implementing a fix for it. This error only occurs on my Window 10 machine. I don't encounter this error on mac (macOS Catalina). I am building the plugin for all IDEs, but I am getting the error in Intellij as well as PhpStorm. 

Here is my build.gradle configuration:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'net.sf.proguard:proguard-gradle:6.2.2'
}
}

plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.17'
}

group 'io.notestash'
version '2020.2.1'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

intellij {
downloadSources false
plugins 'markdown'
}

dependencies {
compile group: 'com.evernote', name: 'evernote-api', version: '1.25.1'
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.4.1'
compile group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '3.1.1'
compile group: 'com.mortennobel', name: 'java-image-scaling', version: '0.8.6'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.1'
compile group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer', version: '20200713.1'
compile 'com.vladsch.flexmark:flexmark-all:0.62.2'
compile ('io.sentry:sentry:1.7.30') {
// Exclude the slf4j transitive dependency. IntelliJ already bundles it.
// You'll get classloader errors if this is bundled with your plugin.
exclude group: 'org.slf4j'
}
testCompile group: 'junit', name: 'junit', version: '4.12'
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
patchPluginXml {
changeNotes """
Release: 2020.2.1<br>
Fixes:<br>
<ul>
<li>Fixed deprecated API usages</li>
<li>Fixed plugin details section</li>
</ul>"""
sinceBuild """193"""
untilBuild """203.*"""
}

Does anyone know what this error means and what has to be done to fix it?

4 comments
Comment actions Permalink

Please try upgrading the gradle-intellij-plugin to 0.6.3.

0
Comment actions Permalink

I tried updating the gradle-intellij-plugin but that didn't seem to have any affect. The same error is encountered. A user using this plugin has also reported seeing the same error using PhpStorm on Ubuntu Linux on Window Subsystem for Linux (WSL2). I don't know if the issue is related to environment or not though. I don't see this error in Intellij on my Mac. Could it have anything to do with the sourceCompatibility setting in build.gradle?

0
Comment actions Permalink

I've only been able to replicate this error in Ubuntu. I've only tried Ubuntu 20.04 but it appears to consistently occur in Ubuntu. I don't see this error on macOS (Catalina), or Windows 10.

0
Comment actions Permalink

Sorry for the delay. Does that error occur in the runtime?

You're building your plugin with IDE 2020.2.1, but the sinceBuild property is set to 193. Please keep in mind that you should use the SDK in the same version as your sinceBuild.

0

Please sign in to leave a comment.