0

I'm using Maven in my project and I have a 3rd party library that uses Xerces. In my project there are some other Maven modules which has in their dependencies some others XML libraries. So my problem is, when I use this third party library in an dependent maven project it works fine. And when I use it in a maven module in my project it generate some exceptions.

org.w3c.dom.ls.LSException: unknown protocol: c
    at com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.writeToURI(DOMSerializerImpl.java:1010)
    at generators.Generator.setConf(Generator.java:1567)

When I debug both projects, I remarked that in the second one it instantiate DOMSerializerImpl class form com.sun.org.apache.xml.internal.serialize package, and in the first one uses org.apache.xml.serialize package. Despite the same dependencies are specified in my pom files of both projects.

The dependencies of this this party library are:

    <dependency>
        <groupId>xml-resolver</groupId>
        <artifactId>xml-resolver</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>serializer</artifactId>
        <version>2.7.1</version>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesSamples</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
    </dependency>

Can anyone help me?

  • What happens if you just use the built in Xerces libraries? – Peter Lawrey Jun 25 '14 at 12:23
  • I don't uses Xerces in my project, but it is used by this library that I depend on it. And, if I create a project using it only and with their dependencies (including Xerces), the execution pass without any exceptions. – ZEMNI Ismail Jun 25 '14 at 12:31
  • If your third party library was built with maven, it should pull in the dependencies it needs. If it doesn't do this already, you need to find out which exact versions it expects. – Peter Lawrey Jun 25 '14 at 12:35
  • Can you provide more information about the that are included in your project pom? The list you have included are from the 3rd party pom, which is helpful, but the details of your pom are needed as well. – Sean Mickey Jun 25 '14 at 12:35
  • try execute "mvn help:effective-pom" and have a look at the dependencies there. anything weird? Also "mvn dependency:tree" helps to figure out where stuff is coming from (I think you know the jars the class is in?). usually the dependency wins that is closest to your module. The depedency:tree goal usually tells which one was chosen in favour of which other one. – wemu Jun 25 '14 at 12:49
  • I found the descreption of the original problem in this question : [Dealing with “Xerces hell” in Java/Maven?][1] [1]: http://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven – ZEMNI Ismail Jun 27 '14 at 16:36

0 Answers0