Pluging development with Apache Batik class loading error.

Answered

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

2 comments
Comment actions Permalink

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.

0
Comment actions Permalink

Thanks Jakub,

implementation( group: 'org.apache.xmlgraphics', name: 'batik-swing', version: '1.12'){
exclude group: 'xml-apis', module: 'xml-apis-ext'
exclude group: 'org.apache.xmlgraphics', module: 'batik-dom'
}

Did the trick.

0

Please sign in to leave a comment.