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

这一生的挚爱 提交于 2019-12-06 20:12:58

问题


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.


回答1:


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>



回答2:


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>



回答3:


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.



来源:https://stackoverflow.com/questions/49107375/getting-java-lang-classnotfoundexception-com-sun-xml-internal-ws-spi-providerim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!