Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 10: Replacement for java.xml.ws conflict

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:

enter image description here

What does it mean and how to fix it so I can use my dependency above instead of java.xml.ws from jdk?

like image 310
nllsdfx Avatar asked May 17 '18 13:05

nllsdfx


2 Answers

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>
like image 105
ZhekaKozlov Avatar answered Nov 06 '22 14:11

ZhekaKozlov


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.

like image 41
Nicolai Parlog Avatar answered Nov 06 '22 13:11

Nicolai Parlog