获取 java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl 尽管定义了依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49107375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 10:16:26  来源:igfitidea点击:

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

javamaventomcatjax-wswebservice-client

提问by talha06

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

尽管我已经定义了我在下面添加的相关依赖项,java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl但在我的应用程序调用 Web 服务时出现异常。

<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.

ps servlet 容器是Apache Tomcat 9.0.4.

p.s. Java version: 9.0.1.

ps Java 版本:9.0.1.

回答by reta

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.

或者(尚未检查但应该可以工作)您可能需要更改要导入 POM 依赖项的范围。

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

回答by Nikolaos Georgiou

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

@reta 回答的第一部分对我有用。这些是来自我的 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>

回答by Roshane Perera

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

似乎该课程com.sun.xml.internal.ws.spi.ProviderImpl不可用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.

在 jdk-8 中可用,我想知道如果可能的话,您是否可以使用 jdk-8 可能会解决问题。

回答by David Canós

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

我在从 Java 8 升级到 Java 11 时遇到了同样的问题。

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

问题是ForkJoinPool 中行为改变,该类加载器是 jdk9 系统类加载器,而不是主线程类加载器,它会产生难以解决的 ClassNotFound 异常。

It better explain and solved in this answer https://stackoverflow.com/a/59444016/878015

在这个答案中更好地解释和解决了https://stackoverflow.com/a/59444016/878015