Pluging development with Apache Batik class loading error.
Hi,
I'm trying to develop a plugin with apache batik.
I'm getting following error.
Caused by: java.lang.ClassCastException: class org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to class javax.xml.parsers.SAXParserFactory (org.apache.xerces.jaxp.SAXParserFactoryImpl is in unnamed module of loader com.intellij.util.lang.UrlClassLoader @5419f379; javax.xml.parsers.SAXParserFactory is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @565a7edb)
Batik is added as simple dependency,
compile group: 'org.apache.xmlgraphics', name: 'batik-swing', version: '1.12'
2020-04-05 16:34:10,256 [ 8136] ERROR - .wm.impl.ToolWindowManagerImpl - IntelliJ IDEA 2019.3.3 Build #IC-193.6494.35
2020-04-05 16:34:10,256 [ 8136] ERROR - .wm.impl.ToolWindowManagerImpl - JDK: 11.0.5; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2020-04-05 16:34:10,256 [ 8136] ERROR - .wm.impl.ToolWindowManagerImpl - OS: Mac OS X
Please sign in to leave a comment.
Samithajay,
SDK provides such classes as well - please verify if you didn't mix the packages importing SAXParserFactory from the different one than expected.
Also, you should consider reusing already available batik packages (wherever it is possible) than bundling your own.
Thanks Jakub,
Did the trick.
@Samithajay Hi, I also encountered the same exception when using haraldk/TwelveMonkeys in a plugin project, I posted a discussion here: https://github.com/haraldk/TwelveMonkeys/issues/729#issuecomment-1410060921
I also tried your solution but found no luck, here is my config in build.gradle:
And here is the exception message:
You should check your build.gradle's implementation section to see if it references SAXParserFactoryImpl. You can find the class by using Cmd+O and then locate which JAR it belongs to, and exclude it. In my case, it was referencing org.apache.xmlgraphics:batik-all, which included too many JARs, so I ultimately resolved it by switching to only reference org.apache.xmlgraphics:batik-util