score:0
if you are in a simple java project, not maven. then just remove the dom-jaxb jar from the libraries.
steps : right click on project -> properties -> java buildpath -> libraries tab -> select on jars such as dom-2.3.0-jaxb-1.0.6(version might differ) -> remove.
now it will build without error.
the error is occurring because "org.w3c.dom.document" is coming from both the removed "dom-2.3.0-jaxb-1.0.6" jar and from java's in-built libraries. removing additional jar will let it come only from java's in-built libraries.
score:0
you need to manually check and remove all the jars (libraries) which has the possibility of conflicting with java.xml
package.
in my case, i edited my .classpath
file and removed the following jars and it resolved the issue:
jtidy.jar, castor-0.9.5.4-xml.jar, xercesimpl.jar, xml-apis.jar
score:0
you can use this code (for example in a unit test) to determine all jars that contain a class:
getclass().getclassloader().getresources("org/w3c/dom/nodelist.class");
this gives you an enumeration
. the easiest way to print this is:
collections.list(e).foreach(system.out::println);
score:0
in a gradle land, you can track down which dependencies are contributing to xml-api
s by running:
gradlew -q dependencies
(or core:dependencies
for the core
project in a multi-project environment).
in my case, xml-apis
was being requested by both net.sourceforge.htmlunit
and xom
, so the solution is to exclude xml-apis
in your build.gradle
as so:
dependencies {
implementation("net.sourceforge.htmlunit:neko-htmlunit:$nekohtmlunitversion") {
exclude group: "xml-apis"
}
testimplementation("xom:xom:$xomversion") {
exclude group: "xml-apis"
}
// ...other dependencies
}
score:1
in my case i was using:
jdk 14
and xmlbeans.jar
library.
i just had to remove the xmlbeans.jar
library and it surely solved the issue.
score:2
just open the configure build path and verify the modules which are all you have added as part of the project, which contains the class files as *
org.w3c.dom
this error, we usually gets in java due to same kind of multiple api packages added in one project.
as, am using the same version as you mentioned, am not facing any issues., so just make sure that you don't have any duplicate modules.
score:2
org.w3c.dom is used in:
<dependency>
<groupid>org.apache.xmlbeans</groupid>
<artifactid>xmlbeans</artifactid>
<version>2.4.0</version>
</dependency>
check if this is imported transitively via some other dependency. exclude the same
add dependency for:
<dependency>
<groupid>org.apache.xmlbeans</groupid>
<artifactid>xmlbeans</artifactid>
<version>2.6.0</version>
</dependency>
score:3
for java 9 and higher delete org.w3c.dom jar file from the class path, and you are done. by the way delete module info file too. you don't need to add the external jar file, its already included in the system library of java 9 and higher.
score:3
in my case, culprit was apache poi library. added exclusion as below
<!-- apache poi library for parsing excel sheets -->
<dependency>
<groupid>org.apache.poi</groupid>
<artifactid>poi-ooxml</artifactid>
<version>5.0.0</version>
<exclusions>
<exclusion>
<groupid>org.apache.xmlbeans</groupid>
<artifactid>xmlbeans</artifactid>
</exclusion>
</exclusions>
</dependency>
score:5
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.
score:8
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.
score:14
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
score:16
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.
Source: stackoverflow.com
Related Query
- The package org.openqa.selenium is accessible from more than one module
- Error modularizing a project with gluon Charm: The package com.gluonhq.charm.down.plugins is accessible from more than one module
- The package com.google.inject is accessible from more than one module
- Java 11 migration: Package is accessible from more than one module issue
- The package is accessible from more than one module (Error fix for using SAX in Eclipse)
- The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml
- The package javax.xml.namespace is accessible from more than one module: <unnamed>, java.xml in eclipse webservice
- Package is accessible from more than one module
- Package accessible from more than one module in Eclipse RCP
- The package javax.servlet.http is accessible from more than one module: servlet.api, tomcat.i18n.es, tomcat.i18n.fr, tomcat.i18n.ja
- The package org.openqa.selenium is accessible from more than one module: htmlunit.driver, phantomjsdriver, selenium, selenium.server.standalone
- eclipse rcp , the packageyyy is accessible from more than one module: <unnamed>
- Excluding dependency does not help to fix "The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml"
- Can I have more than one class containing the main() method in a Java project?
- Can one java executable run more than one loop at the same time
- Eclipse is confused by imports ("accessible from more than one module")
- How can I launch more than one debug session in Eclipse from a single click?
- More Matchers recorded than the expected - Easymock fails from Maven and not from Eclipse
- Why an executable jar when run from a command line uses much more ram, than the same project run from Eclipse?
- In eclipse is there a way to run more than one Java app in different console windows?
- The package java.util.logging is not accessible in Java
- More than one scala library found in the build path when fresh creating maven project in eclipse
- [HTTP:101380]There is more than one Web fragment with the same name: "spring_web"
- In Eclipse, any way to start application in more than one emulator at the same time?
- Using java class from one package in main of another package (Same project)
- Java - Rational Team Concert - Load more than one stream workspace at same time
- Select one option from many options in drop down list in Eclipse using java when run code for the android device
- Print more than one page with Printable on Java
- Java Eclipse, new line after method if include more than one line?
- Opening more than one of the same Mac Application at once
More Query from same tag
- How can I import the "starter project" of the Play Framework into Eclipse? (Once I have downloaded it from the official website.)
- Getting log4j2 to work with eclipse
- Use Eclipse classpath variable to replace absolute "sourcepath" path?
- Eclipse Pydev: mysterious error every time running Pydev console
- how to put six editbox horizontally
- Maven not displaying in Eclipse
- How to install EGit plugin in Eclipse manually
- Which tools to use for Grails Development
- java.lang.RuntimeException: Unable to start activity ComponentInfo (android eclipse)
- Eclipse freezes all the time with Ubuntu
- os.detected.classifier not set - os-maven-plugin and eclipse oxygen
- How can I get all annotations within a class using ICompilationUnit
- Compiler Compliance Error in Eclipse
- disable back button on in ltk wizardinputpage
- Stop Eclipse/Subversive from setting svn:mime-type to text/plain on initial commit
- Git commit combined two repositories into one
- Eclipse shows errors until I clean
- Egit: unable to çheckout new branch
- Limit "Find References" in Eclipse to only references from my code
- A quiz using DataBase SQlite
- JBoss v4.2 in Eclipse, getting config parsing exceptions
- How to use Egit with ssh
- Eclipse: How to overwrite resources in src folder
- How to get binary file using eclipse c++?
- I can't find source and design tab in eclipse kepler
- Any way to selectively enable/disable debugging on android
- Folders within working sets?
- Eclipse - How to open and set breakpoints in code attached to the target platform plugins?
- .so in a .jar (Eclipse)
- Android: How can I use the Button background(style)