Using batik svg libraries causes problems with xerces.

XMLWordPrintable

      I'm trying to include batik-anim, batik-bridge, and batik-svg-dom as dependencies for our add-on. However, doing this causes a run-time exception:

      java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
      	at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
      	at org.apache.batik.dom.util.SAXDocumentFactory.<clinit>(Unknown Source)
      	at com.lucidchart.core.svg.parser.SVGParser.parse(SVGParser.java:56)
      	at com.lucidchart.core.svg.importer.SVGImporter.convert(SVGImporter.java:30)
      	at com.lucidchart.core.svg.common.SVGConverter.importSVG(SVGConverter.java:23)
      	at com.lucidchart.onprem.confluence.servlets.ImportVisioAttachment.importSvgFromStream(ImportVisioAttachment.java:371)
      	at com.lucidchart.onprem.confluence.servlets.rest.Shapes.doPost(Shapes.java:80)  
      

      I've tried a variety of exclusions and dependencies, but it either won't compile:

      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project lucid-onprem-confluence: Compilation failure
      [ERROR] /home/tpope/lucid/main/visio-service/app/com/lucidchart/core/svg/parser/SVGParser.java:[64,20] cannot access org.w3c.dom.xpath.XPathEvaluator
      [ERROR] class file for org.w3c.dom.xpath.XPathEvaluator not found
      

      if I exclude too many things, or causes the error with different SAXParserFactory classes.

      I tried advice from several online sources:
      https://answers.atlassian.com/questions/19696121/answers/27329731
      https://answers.atlassian.com/questions/104121/im-blocked-help-cannot-be-cast-to-javax.xml.parsers.saxparserfactory
      http://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven
      http://stackoverflow.com/questions/19992400/classcastexception-org-apache-xerces-jaxp-documentbuilderfactoryimpl-cannot-be
      that seemed to have similar problems, but to no avail.

      I've attached our version.xml along with our pom.xml in a state that compiles but throws the runtime error, with most of the excludes that I've tried currently in it.

        1. pom.xml
          16 kB
          Taylor Pope
        2. version.xml
          1 kB
          Taylor Pope

            Assignee:
            Unassigned
            Reporter:
            Taylor Pope
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: