"The package javax.xml is accessible" error... but only in test classes? [message #1849856] |
Fri, 04 February 2022 18:50 |
Dan Royer Messages: 9 Registered: May 2014 |
Junior Member |
|
|
Hello, friends,
The project is https://github.com/MarginallyClever/Makelangelo-software in Java15 + Eclipse 2021-12 (4.22.0). After accepting a PR I am getting a lot of
The package javax.xml is accessible from more than one module: <unnamed>, java.xml
I use java.xml in application and in junit tests. The error appears ONLY in my test classes, not in my app classes. Nobody else involved seems to have this problem and I'm the only Eclipse user.
I have a src/main/java/module-info.java. JavaSE-15 is on the modulepath and Maven dependencies are on the classpath. Some of my dependencies are no longer supported and cannot be updated (org.kabeja). I'm not sure what is relevant to this bug, just trying to give all the information.
Naturally I tried refresh, then Maven update, then googled for a couple hours and I'm still stuck.
Do you know why I'm getting this error and what to do about it?
Thank you!
[Updated on: Fri, 04 February 2022 18:51] Report message to a moderator
|
|
|
Re: "The package javax.xml is accessible" error... but only in test classes? [message #1849858 is a reply to message #1849856] |
Fri, 04 February 2022 21:18 |
David M. Karr Messages: 810 Registered: July 2009 |
Senior Member |
|
|
I ran into this when I first started testing with post-java8 (java11). It's a little awkward to find the resolution to this, but the steps are "straightforward", at least.
In Java 9 and newer, it is invalid to include classes in the "java.xml.*" package in jar files other than the "legal" jar files for that package. In general, that's a bad thing to do, but now Java 9 protects you from it. I don't remember the details of how that works, but that's essentially what's happening.
What the error message is telling you is that some jar file, somewhere in your classpath, has one or more classes that are declared to be in the javax.xml.* package. At this point, you're wondering, ok, WHICH jar file has these offending classes?
Here's the straightforward, but potentially labor-intensive strategy for finding the jar file in question:
Do "Open Type". Enter "javax.xml." Look at the pages and pages of potential matches. You'll see that many of the instances are in the JDK. Your job at this point is to look at ALL the results, ignoring the ones in the JDK. For each one, check to see if the artifact on that line is a dependency of your project. You'll probably see "xml-apis" as one of them. Somewhere in that long list you're going to find an artifact that is one of your dependencies. You'll need to exclude that artifact from your dependencies, most likely a transitive exclusion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05010 seconds