Getting java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl despite the dependencies are defined
Asked Answered
I

5

35

Despite that I have defined the related dependencies as I have added below, getting the java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl exception when my app makes a call to the web service.

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.2.10</version>
</dependency>

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

p.s. The servlet container is Apache Tomcat 9.0.4.

p.s. Java version: 9.0.1.

Ionization answered 5/3, 2018 at 9:43 Comment(2)
Got this error when migrating a soap client code from JDK8 to JDK21. Getting java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl. Error got was resolved with FastInfoset-1.2.18.jar gmbal-4.0.1.jar ha-api-3.1.12.jar jakarta.activation-1.2.2.jar jakarta.activation-api-1.2.2.jar jakarta.annotation-api-1.3.5.jar jakarta.jws-api-2.1.0.jar jakarta.xml.bind-api-2.3.3.jar jakarta.xml.soap-api-1.4.2.jar jakarta.xml.ws-api-2.3.3.jarjaxb-impl-2.3.3.jar jaxws-rt-2.3.3.jar management-api-3.2.2.jarmimepull-1.9.13.jar pfl-basic-4.1.0.jar pfl-tf-4.1.0.jar policy-2.7.10.jarParapet
Continuation to jars list saaj-impl-1.5.2.jar stax2-api-4.1.jar stax-ex-1.8.3.jar streambuffer-1.5.9.jar woodstox-core-5.1.0.jarParapet
H
26

The first part of the answer by @reta works for me. These are the relevant dependencies from my pom (Java 10):

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.3.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>rt</artifactId>
  <version>2.3.1</version>
</dependency>
Hypersensitive answered 5/10, 2018 at 11:6 Comment(2)
It works until version com.sun.xml.ws:rt:2.3.5. It didn't work with version >3.x.xGameness
It works for me with version com.sun.xml.ws:jaxws-rt:4.0.2.Borrero
C
22

Today in the era of Jakarta, I needed the following two dependencies:

        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <version>2.3.3</version>
        </dependency>

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

One thing I find quite weird is that the second dependency is not from Jakarta, I thought all of these implementations were migrated. It works, but I'd appreciate if someone could comment on that.

Constantan answered 2/6, 2020 at 9:50 Comment(2)
I agree. I am facing a problem with com.sun.xml.ws:jaxws-rt on Android, because the lib is using Java API that is not available on Android. I was expecting "the era of Jakarta" to be platform agnostic.Explanatory
Before 3.0.0, the jars were renamed to jakarta but they still contain javax packages inside which means they're compatible with the com.sun stuffBushwhacker
M
17

It seems like you may need to include this dependency:

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

Or (haven't checked it yet but should work) you may need to change the scope to import for POM dependency.

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-rt</artifactId>
  <version>2.2.10</version>
  <type>pom</type>
  <scope>import</scope> 
</dependency>
Mississippian answered 18/5, 2018 at 13:49 Comment(1)
ty for this answer. PEOPLE! those 2 dependencies are different. One is rt and other is jaxws-rt. After adding this dependency, if you get a SOAPVersion exception, upgrade the version to latest. At the time of writing, latest version is rt is 2.3.1Sarisarid
J
3

I've got the same problem upgrading to Java 11 from Java 8.

The problem was change of behavior in ForkJoinPool, which classloader is as of jdk9 system classloader, not the main thread classloader, it can produce hard to solve ClassNotFound exceptions.

It's better explained in this answer https://mcmap.net/q/161867/-completablefuture-forkjoinpool-set-class-loader

Jaret answered 22/12, 2019 at 15:42 Comment(0)
R
-1

Seems like the class com.sun.xml.internal.ws.spi.ProviderImpl is not available in jdk-9

jshell> Class.forName("com.sun.xml.internal.ws.spi.ProviderImpl")
|  java.lang.ClassNotFoundException thrown: com.sun.xml.internal.ws.spi.ProviderImpl
|        at URLClassLoader.findClass (URLClassLoader.java:466)
|        at DefaultLoaderDelegate$RemoteClassLoader.findClass (DefaultLoaderDelegate.java:66)
|        at ClassLoader.loadClass (ClassLoader.java:543)
|        at ClassLoader.loadClass (ClassLoader.java:476)
|        at Class.forName0 (Native Method)
|        at Class.forName (Class.java:292)
|        at (#1:1)

which is available in jdk-8, I wonder if you can use jdk-8 if possible might solve the issue.

Retrochoir answered 5/3, 2018 at 11:1 Comment(1)
downgrading to JDK8 is not a solutionChutzpah

© 2022 - 2024 — McMap. All rights reserved.