XML parse fail using JDOM

Hi, 

I'm trying to parse XML in plugin use JDOM (for code reuse purpose), but when I call 

 

SAXBuilder builder = new SAXBuilder();

builder.build(xmlFile);



It crashed for this:

Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser cannot be cast to org.xml.sax.XMLReader

 

I think the version of xerces in the idea lib is too low, any solutions?

0
1 comment

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, fixed!

0

Please sign in to leave a comment.