Telebh
Telebh

Reputation: 345

XML-api.jar and org.xml.sax classes having issues with JAVA 11

[![enter image description here][1]][1]I am getting compilation error for classes refer to org.xml.sax and xml-apis using Eclipse 2019-03 and OpenJDK 11. I have deleted any maven dependency to xml-apis though it still shows in Maven repository and listed in Maven dependecies. I have set Maven dependencies before JDK in Order & export of project build path and vice versa but with no hope.

import org.xml.sax.*;
import org.xml.sax.ext.*;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.DefaultHandler;

I had to add the update here because of comment limited length:

Yes, I did checked Maven dependency hierarchy and found that Maven dependency

            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency> --> AND <!-- <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency> --> ```
includes xml-apis, I have commented that out both dependencies, but then I got compilation error to a class that refers to "org.apache.xerces.parsers.DOMParser" that I have to uncomment "xerces" dependency again and of course same problem happening because JDK have the classpath for java.xml which includes "org.w3.dom" and "rg.xml.sax"
[![enter image description here][2]][2]

[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/m1li4.jpg

Upvotes: 0

Views: 12069

Answers (1)

Telebh
Telebh

Reputation: 345

after checking Maven dependency hierarchy of pom file as suggested by @howlger I was able to find xerces has dependency on xml-apis, after excluding it, worked fine.

<dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
            <exclusions>
            <exclusion>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            </exclusion>
            </exclusions>
        </dependency>

Upvotes: 4

Related Questions