close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml Error Occurs?

Today I am facing the following error The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml in Java.

How To Solve The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml Error ?

  1. How To Solve The package org.w3c.dom is accessible from more than one module: , java.xml Error ?

    To Solve The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml Error 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

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

    To Solve The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml Error 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

Solution 1


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

Solution 2

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.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read