Java 11 package javax.xml.soap does not exist

Boris :

I'm trying to create a simple message using SOAP:

MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();

When I build the project with Java 8 it's fine, but building it with Java 11 fails with a compilation error:

package javax.xml.soap does not exist

How do I fix the issue?

Boris :

JAX-WS removed from Java 11

JAX-WS is no longer bundled with Java 11.

According to the release notes, Java 11 removed the Java EE modules:

java.xml.ws (JAX-WS, plus the related technologies SAAJ and Web Services Metadata) - REMOVED
  • Java 8 - OK
  • Java 9 - DEPRECATED
  • Java 10 - DEPRECATED
  • Java 11 - REMOVED

See JEP 320 for more info.

You can fix the issue by using alternate versions of the Java EE technologies. Simply add a com.sun.xml.ws : jaxws-ri Maven artifact that contains the technologies you need:

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-ri</artifactId>
  <version>2.3.2</version>
  <type>pom</type>
</dependency>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=37043&siteId=1