"The package javax.xml is accessible" error... but only in test classes? [message #1849856] |
Fri, 04 February 2022 13:50  |
Eclipse User |
|
|
|
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 13:51] by 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 16:18   |
Eclipse User |
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: "The package javax.xml is accessible" error... but only in test classes? [message #1856761 is a reply to message #1856748] |
Thu, 29 December 2022 08:34  |
Eclipse User |
|
|
|
Hi Ed,
Right? There are individual mains as entry points, those bring up the worldwind 3D globe. I set to start from one of those to test.
I *think* I have it building and creating the worldwind.jar file... I will just have to wing it from here. if I can get the apis built and changed as I need for other work, I will call it success! It will make debugging more stressful - but if this work were easy, everyone would be doing it.
|
|
|
Powered by
FUDForum. Page generated in 0.05502 seconds