29

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.

talha06
  • 6,206
  • 21
  • 92
  • 147

5 Answers5

23

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>
Nikolaos Georgiou
  • 2,792
  • 1
  • 26
  • 32
19

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.

JohnEye
  • 6,436
  • 4
  • 41
  • 67
  • 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. – mihca Jan 20 '22 at 08:50
  • 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 stuff – PentaKon Jun 20 '23 at 14:49
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>
reta
  • 766
  • 6
  • 8
  • 2
    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.1 – Faraz Oct 19 '18 at 17:12
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://stackoverflow.com/a/59444016/878015

David Canós
  • 1,806
  • 18
  • 19
-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.

Roshane Perera
  • 132
  • 1
  • 6