JDK 11; JAX-WS; Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
Asked Answered
S

7

53

I Need to access legacy SOAP webservices in JDK 11. But I am suffering "ProviderImpl not found."

The JDK 11 implementation is: zulu11.2.3-jdk11.0.1-win_x64.

In my build.gradle, I have the following dependency:

compile group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.3.1', ext: 'pom', { force = true }

My WAR file's WEB-INF/lib contains enter image description here

I am seeing:

javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
    at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:103) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:112) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.Provider.provider(Provider.java:96) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.Service.<init>(Service.java:112) ~[jaxws-api-2.3.1.jar:na]

Following https://github.com/javaee/metro-jax-ws/issues/1247 I have tried setting:

-Djavax.xml.ws.spi.Provider=com.sun.xml.ws.spi.ProviderImpl

But I still get:

javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
    at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:103) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.FactoryFinder.fromSystemProperty(FactoryFinder.java:122) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:99) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.Provider.provider(Provider.java:96) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.Service.<init>(Service.java:112) ~[jaxws-api-2.3.1.jar:na]
    ...
Caused by: java.lang.ClassNotFoundException: com.sun.xml.ws.spi.ProviderImpl
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    at javax.xml.ws.spi.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:90) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:123) ~[jaxws-api-2.3.1.jar:na]
    at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:101) ~[jaxws-api-2.3.1.jar:na]
    ... 22 common frames omitted

I have verified that com.sun.xml.ws.spi.ProviderImpl IS available:

enter image description here

Is there a known working example of this combination available "out there"?

Thoughts/suggestions gratefully accepted.

Sheffield answered 4/1, 2019 at 2:52 Comment(4)
I think JAX-WS uses the thread context class loader when trying to load the JAX-WS implementation so it might be useful to get its value (Thread.currentThread().getContextClassLoader) when trying to debug this.Litharge
That's an idea...I had stuff working until I tried putting the webservice calls into CallableFutures. Interestingly, they are working OK inside plain Futures...so this may not be a real thing.Sheffield
anyone got an answer for this? legacy 3rd party jars dont work in jdk 11Corbin
There seems to be some progress, see github.com/eclipse-ee4j/jax-ws-api/issues/90Torosian
G
49

I got the exact same error calling soap-webservices in java11. I finally got it to work in my testproject by adding the following dependency to pom.xml

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>rt</artifactId>
    <version>2.3.1</version>
</dependency>

As my production environment is not converted to maven yet, I then found out that I needed these jar-files on the classpath:

jaxb-runtime-2.3.1.jar
jaxws-api-2.3.1.jar
javax.xml.soap-api-1.4.0.jar
rt-2.3.1.jar
streambuffer-1.5.3.jar
policy-2.7.5.jar
stax-ex-1.8.jar
javax.jws-api-1.1.jar
saaj-impl-1.5.0.jar
gmbal-api-only-3.1.0-b001.jar 
Griffith answered 15/5, 2019 at 11:1 Comment(2)
Well, RI 2.3.2 is now out under the eclipse foundation 'umbrella' (projects.eclipse.org/projects/ee4j.jaxws). I wonder if this has improved anything. I can't find meaningful release notes, however....Sheffield
RT 3.0.1 is out as of writing but this broke everything for me as it upgraded glassfish to be incompatible with other components, had to delete my gradle cache to get back where I was!Aeon
P
18

I worked this out with this artifact:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.5</version>
</dependency>

or gradle

implementation 'com.sun.xml.ws:jaxws-rt:2.3.5'

You can check other versions and which artifacts depends this one here: https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt/2.3.5 .

Pernick answered 22/12, 2021 at 15:54 Comment(0)
C
5

I had the same issue. I later found out that having moved from javax packages to jakarta packages you will also have to import the correct dependencies. At the time of this comment the latest is 4.0.1. However, I think any version from 3.0.1 should work with Jakarta. You will need to import:

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>rt</artifactId>
        <version>4.0.1</version>
    </dependency>
Clutter answered 27/6, 2023 at 9:37 Comment(0)
A
4

After going through lots of official documents and methods of trial and error, I have finally found the correct configuration, which is as per follows,

Add below dependancy in .pom file,

    <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.ws</groupId>
        <artifactId>rt</artifactId>
        <version>2.3.2</version>
    </dependency>

To include JAR responsible for loading these classes into restart classloader (used in spring-devtools), update /src/main/resources/META-INF/spring-devtools.properties like below,

restart.include.jax=/jaxws-rt.*.jar

Affected answered 4/11, 2022 at 16:56 Comment(0)
L
2

I got the same error as well. From a Spring application I called an OSGI bundle which did a SOAP request. Right before the call within that OSGI bundle a class loader switch solved the problem.

Use the classloader from your SOAP Service class and reset the classloader after the call.

    final ClassLoader targetClassLoader = ServiceXY.class.getClassLoader();
    final Thread currentThread = Thread.currentThread();
    final ClassLoader contextClassLoader = currentThread.getContextClassLoader();
    try {
           currentThread.setContextClassLoader(targetClassLoader);
           //here call your Service 
    } finally {
           currentThread.setContextClassLoader(contextClassLoader);
    }

JEE libs have been removed with Java 9, JEE-specific libs / implementations must now be made available by the application via thirdparty libraries - e.g. jaxws-api.jar and jaxws-rt.jar. This code of JEE libs often still expects to be part of the jre system library and with that of the application classloader - but it isn't anymore. So if service classloader ServiceXY.class.getClassLoader() and your application classloader Thread.currentThread().getContextClassLoader() are different you need to switch for the request.

Loupe answered 1/4, 2020 at 23:54 Comment(0)
M
2

Another solution is to replace javax.xml.ws with jakarta.xml.ws:

implementation 'jakarta.xml.ws:jakarta.xml.ws-api:4.0.1'

replace all the imports and if you have this remove it:

System.setProperty("javax.xml.ws.spi.Provider", "com.sun.xml.ws.spi.ProviderImpl")
Moazami answered 27/11, 2023 at 22:14 Comment(0)
A
0

For me, I need @WebService annotation in the code. And I got the same error in Java 11 with jakarta.jws.WebMethod. I tried all the solutions above, but not working for me.

Then I shifted to Java 8 and used javax.jws.WebMethod. It is working.

Amphichroic answered 22/9, 2023 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.