When trying to setup a project with a Java version > 9 I came across a problem with dependencies and the Java module system. I know that there are some posts regarding this topic (eg this one or this one ), but the solutions (exclude packages from dependencies) don't seem to help in my case.
On some imports related to XML parsing, I get the following error The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml
I used the "Open Type" dialog and found that there are in fact two providers for eg org.w3c.dom.Document.
This rmlmapper-4.9.1.jar is currently the only maven dependency in my project and I tried to exclude xml-apis as suggested here . I also added org.w3c.dom as you can see.
<dependencies>
<dependency>
<groupId>be.ugent.rml</groupId>
<artifactId>rmlmapper</artifactId>
<version>4.9.1</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>org.w3c</groupId>
<artifactId>dom</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Unfortunately, this doesn't help and the error persists. Note that I can build the project but get errors at runtime. Am I excluding the wrong packages? I couldn't find a package providing org.w3c.dom
using mvn dependency:tree
so how can I find the packages that need to be excluded?
From the Eclipse snapshot you provide, it seems the package org.w3c.dom
is embedded in the rmlmapper
dependency Jar itself (the Jar is probably bundling its own dependencies in it). Therefore the exclusion
will not work as it only excludes transitive dependencies (not bundled packages). Even though it's possible to exclude the package , another approach is to exclude the java.xml
module with the --limit-modules
option as answered here . Note that you might have to do this with other modules if rmlmapper
also bundles other JDK classes.
Either way, the best solution is to contact the owner of the rmlmapper
library and let them know of the issue on Java 9+, as maybe they did not upgrade their project to support that version.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.