Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 233
talha06 Avatar asked Mar 05 '18 09:03

talha06


4 Answers

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> 
like image 150
Nikolaos Georgiou Avatar answered Oct 07 '22 02:10

Nikolaos Georgiou


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> 
like image 37
reta Avatar answered Oct 07 '22 03:10

reta


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.

like image 37
JohnEye Avatar answered Oct 07 '22 01:10

JohnEye


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

like image 29
David Canós Avatar answered Oct 07 '22 03:10

David Canós