'Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found after upgrading to java 11.How to fix?

I'm using bw application.JDK 8 is upgraded to JDK 11.At line SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(), getting exception as java.lang.ClassNotFoundException: javax.xml.soap.SOAPMessage cannot be found. Added javax.xml.soap-api-1.4.0.jar in classpath,though the above error is not seen,getting the following exception.
javax.xml.soap.SOAPException: Unable to create message factory for SOAP: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found. I've added saaj-impl-1.5.1.jar in classpath as suggested in a few posts,but the error isn't going away.Can anyone help with this?



Solution 1:[1]

I had the same problem. In addition to dependencies

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>rt</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.3.2</version>
    <type>pom</type>
</dependency>
<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>

I also had to set System property.

System.setProperty("javax.xml.soap.MetaFactory","com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");

Only after that, I got rid of SOAPException.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vaske