I have to use java.xml.ws*
components in my project but because it's deprecated and will be removed soon I want to use replacement for these components. So I added this dependency to my project's pom
file:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
This is my module configuration:
module x.y.z {
requires kotlin.stdlib;
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.context;
requires cxf.core;
requires cxf.rt.frontend.jaxws;
requires java.xml.ws;
}
But there is an error:
What does it mean and how to fix it so I can use my dependency above instead of java.xml.ws
from jdk?
Just use Java 11 :) There is no javax.xml.ws
module there, so no conflict.
As for Java 10, the easiest workaround is to change the scope of jaxws-ri
to runtime
:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<scope>runtime</scope>
</dependency>
By adding requires java.xml.ws
you tell the module system that you depend in the deprecated Java EE module java.xml.ws, which it will then resolve and make available. At the same time there seems to be a module of the same name on the module path. (Maybe a JAR pulled in by jaxws-ri?)
Although, come to think of it, I would have expected a compiler message complaining of duplicate modules... It looks like the error (is it compiler or runtime?) comes from an IDE. What happens if you run the build with Maven?
Anyways, if you are willing to start with Java 11, you could give that a try. The Java EE modules are removed, so there is no chance of a platform module interfering. I'm not sure whether it is possible to add a java.* module on the module path, though.
If it is not or you prefer to stick to Java 10, you should take a look at upgreadable modules and the --upgrade-module-path
option. That way you can use the JARs that provide the JAX WS API to replace the platform module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With