The package org.w3c.dom is accessible from more than one module: , java.xml.

We Are Going To Discuss About The package org.w3c.dom is accessible from more than one module: , java.xml. So lets Start this Java Article.

The package org.w3c.dom is accessible from more than one module: , java.xml

  1. The package org.w3c.dom is accessible from more than one module: , java.xml

    I had a similar issue because of a transitive xml-apis dependency. I resolved it using a Maven exclusion:
    <dependency> <groupId>org.apache.xmlgraphics</groupId> <artifactId>fop</artifactId> <version>0.95</version>

  2. The package org.w3c.dom is accessible from more than one module: , java.xml

    I had a similar issue because of a transitive xml-apis dependency. I resolved it using a Maven exclusion:
    <dependency> <groupId>org.apache.xmlgraphics</groupId> <artifactId>fop</artifactId> <version>0.95</version>

Solution 1

I had a similar issue because of a transitive xml-apis dependency. I resolved it using a Maven exclusion:

<dependency>
    <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>fop</artifactId>
    <version>0.95</version>
    
    <exclusions>
        <exclusion>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Another dependency that just causes trouble and I don’t have a solution other than removing it is this one:

<dependency>
    <groupId>com.oracle.database.xml</groupId>
    <artifactId>xmlparserv2</artifactId>
    <version>${oracle.version}</version>
</dependency>

Use mvn dependency:tree to see who brings in the transitive dependency, and then exclude that from there.

Original Author Lukas Eder Of This Content

Solution 2

Disappointingly I don’t see any compiler flags to show what jar the problem is with
Even -Xlint:module doesn’t seem to show up anything useful and eclipse doesn’t shed any light on the issue

Instead to find where org.w3c.dom comes from I’ve been using this script:

mvn dependency:copy-dependencies -DincludeScope=test -DoutputDirectory=deps
for i in deps/*.jar; do if unzip -l $i| grep -q org.w3c.dom; then echo $i; fi ; done

Strictly you don’t have to specify the scope test as that’s the default but I’ve included it as you might want to use compile instead

Original Author MSillence Of This Content

Solution 3

On my side, I’ve spent a few hours to understand my issue, really closed to this one.
The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml

I wanted to migrate a project from Java 8 to Java 11. A few library issues. Easy to fix. But on this one,

  • I’ve tried to create module-info.java → it was worst.
  • Find a issue on my OS (debian 10)
    → even if Java 11 was default JRE, $JAVA_HOME was not rightly set for
    maven build. And when I was thinking it was only an Eclipse issue, I finally consider that it was a global compilation problem. To fix this I had to add following line in ~/.mavenrc

    JAVA_HOME=/usr/lib/jvm/default-java

  • Deep analysis on maven dependencies shows me a third-level dependency on xom.jar which trigger the issue. Dependency was linked to Saxon HE library → an upgrade to VERSION 9.9.X has resolved this boring problem.

Hope this will helps other people.

Original Author Damien C Of This Content

Solution 4

In my case, it was caused by combining the usage of:

  • JDK 11
  • dom4j 2.1.3 library

As pointed out by others, the root cause is that dom4j and its dependencies (e.g., pull-parser) use some packages names (javax.xml.parsers, org.w3c.dom) that have been used by the JDK.

I had to remove dom4j to solve the problem. Just use JDK’s own XML api.

Original Author zico Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment