First of all I researched a lot about this issue already and it's is not a duplicate of the numerous and typical "The package * is accessible from more than one module: <unnamed>, java.xml" questions for which the simple answer is: "remove duplicate dependencies from your classpath".
This we already did and for the colleagues using IntelliJ IDE it also is working fine and not bringing up the issues Eclipse does.
I suspect it to be a side-effect of the special setup of the project which Eclipse is not handling well and therefore is leading to the issue. But one after the other:
Issue
In the end it's a "typical" "The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml" issue. But unlike having defined redundant, conflicting dependencies, it's more due to the special project setup and Eclipse not properly handling the project setup, since the conflicting dependencies both come from the same system library JRE.
From the server module:
Project Background
We are working on the project for a long time now (big legacy project). During the work we've already upgraded from Java 1.6 over Java 1.8 to now Java 17. All the upgrades were fine so far except the last one. But only with the introduction of Java 17 also the new module server-util was introduced, which seems to cause the issues (see below).
When using Java 1.8 in the Compiler-Options the project also is compiling fine, but as soon the Compiler-Options are increased to >Java 9 (e.g. 17) the compile issues occur.
Tools
- Eclipse 2021_06 (but the issues also occur with latest Eclipse 2023_09)
- Java 17 (jdk-17.0.5+8)
- Gradle (Wrapper) 7.4.2
- Our project doesn't use module-info.java thus should reside in the default unnamed module
Project Setup
The project is structured into 4 modules: client, server, share and server-util. Whereby client and server usually are independend modules and the share is shared between the two. server-util is a small utility module which provides additional utilities/ services for the server module.
A graphical representation would look like this:
client server - server-util
\ /
share
All of the modules except the server-util module are "simple" Java-Projects (so no Maven or Gradle is in place here (yet)). The build tool used for this modules is Ant. Only the server-util module makes use of Gradle.
Observations/ Issue
- When switching the Compiler-Options from 1.8 to 17 as explained above the issues start to occur. Interestingly the issues only arise between the
serverandserver-utilmodules.client - shareandserver - sharedon't show this kind of issues. - When tracing down the conflicting dependencies they both originate from the configured default JRE for the workspace which is a JDK 17 (both
servermodule andserver-utiluse the same). But during the trace once it's opened fromservermodule and once fromserver-utilmodule (-> in the Package Explorer view). Therefore it seems Eclipse doesn't recognize it's the same JRE/ JDK being used within the projects (whereby it does recognize it between theclient - shareandserver - sharemodules and therfore doesn't bring up the issues). - Since
server-utilproject is a Gradle project Eclipse offers theGradle -> Refresh Gradle Projectoption in the context menu. Usually when I perform this operation this also leads to compile issues, since the usually configured JRE isn't recognized anymore or even actively reset. => When opening the Build Path of the module none of the available JREs is selected/ configured anymore. I always need to manually select "Workspace default JRE" (-> JDK 17) again.
Assumption
Since the setup is working for the colleagues using IntelliJ IDE and also at Build Time (-> Ant) and runtime everything is working fine I don't think it's a general or plain dependency issue.
My assumption is that Eclipse cannot handle the relationship between the server and server-util projects well. And the most obvious reason is that one is a plain, "simple" Java Project, whereby the other is a Gradle project. Therefore Eclipse doesn't seem to properly detect the usage of the same "system library -> JRE" and therefore falsely is claiming the error "The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml".
But it's not exactly clear if it's the combination of both or maybe even solely related to the Gradle project itself (whether it's our project's setup or some kind of issue with the Eclipse Gradle plugin or so).
I've tried different things like
- Using different Eclipse versions (from 2021_06 till finally latest 2023_09)
- Changing Module Dependencies from Build Path settings
- Using different Build Path settings like configuring the JRE in different ways
- Moving the JRE from the "Modulepath" section to the "Classpath" section according to this question: In Eclipse, what is the difference between modulepath and classpath?. But as also mentioned in the question the JRE always remains in the "Modulpath" section
So none of this helped.
I hope someone may have some experience with this and some other ideas to resolve the issues, even though the setup (plain Java-Project depending on Gradle project) may be quite special.
EDIT:
The dependencies server-util brings (in order of definition)
Implementation scope
javaee-api-8.0.jar
slf4j-api-1.7.21.jar
antlr-2.7.7.jar
byte-buddy-1.11.20.jar
cache-api-1.1.0.jar
classmate-1.5.1.jar
dom4j-2.1.3.jar
ehcache-3.9.7.jar
hibernate-commons-annotations-5.1.2.Final.jar
hibernate-core-5.6.1.Final.jar
hibernate-jcache-5.6.1.Final.jar
jandex-2.2.3.Final.jar
javassist-3.24.0.GA.jar
jboss-logging-3.4.2.Final.jar
FastInfoset-1.2.15.jar
activation-1.1.jar
istack-commons-runtime-3.0.7.jar
javax.activation-api-1.2.0.jar
javax.mail-1.6.2.jar
javax.persistence-api-2.2.jar
jaxb-api-2.3.1.jar
jaxb-runtime-2.3.1.jar
jboss-transaction-api_1.2_spec-1.1.1.Final.jar
stax-ex-1.8.jar
txw2-2.3.1.jar
xml-apis-1.0.b2.jar<-- may be the issue, but I'm still surprised why it didn't show up wile "tracing" it down & why it's compiling fine with IntelliJ ...)
Test scope
- h2-1.4.200.jar
- jmockit.jar
- jmockit-deencapsulation.jar
- junit-4.11.jar
- hamcrest-all-1.3.jar
- ojdbc8.jar
- osdt_cert.jar
- osdt_core.jar




<unnamed>module. Two modules must not contain the same package. Please read stackoverflow.com/a/55572922/6505250 and stackoverflow.com/a/53824670/6505250 But if you don't want to stick to the Java language specification, here you go (not recommended): stackoverflow.com/a/74890645/6505250server-utithere