ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
问题 This problem ties in with the many discussions about the Xerces dependency hell, but I can't seem to solve it. I'm trying to export LaTeX code to PDF in Java. My code is part of an OSGI bundle for Cytoscape 3.4 and is managed and built with Maven. The LaTeX library is jlatexmath (1.0.6) and to write to SVG and PDF I want to try the apache fop (0.95) libs. Fop is depending on a whole range of batik libraries, which in turn depend on xml-apis (1.3.04). With xml-apis included, I get this error: