java.lang.ClassNotFoundException:javax.xml.ws.WebServiceProvider

问题描述 投票:0回答:1

我需要一些有关从 Java 8 到 Java 17 的项目迁移的帮助。我已将所有已弃用的库更新为与 Java 17 兼容的库。该项目在 IntelliJ 中成功构建,但在 Tomcat 9 上部署时遇到以下错误:

[2024-06-19 06:02:58,822] Artifact test:war exploded: Artifact is being deployed, please wait...

19-Jun-2024 18:03:00.206 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method [manageApp]

    java.lang.IllegalStateException: Error starting child
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:686)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:658)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662)
        at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1782)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:294)
        at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:814)
        at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
        at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:460)
        at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:408)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    Caused by: java.lang.TypeNotPresentException: Type javax.xml.ws.WebServiceProvider not present
        at java.base/sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:47)
        at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:89)
        at jdk.proxy2/jdk.proxy2.$Proxy2.value(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: javax.xml.ws.WebServiceProvider
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1412)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1220)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)

请注意,我已经将 javax 相关库更改为 jakarta。关于可能导致此问题的原因以及如何解决它有什么见解吗?

预先感谢您的帮助!

java migration tomcat9
1个回答
0
投票

根据这个问题的投票答案(tomcat-9-jdk-14-java-lang-noclassdeffounderror-javax-xml-ws-webserviceref),您将需要将 jakarta 依赖项添加到 Tomcat lib 目录。请注意,您希望拥有 Jakarta 而不是 javax 库,因为这是您编译项目所用的。

我最终能够通过将以下 JAR 添加到 Tomcat 的 lib 文件夹(JAX WS API 及其所有依赖项)来解决此问题:

© www.soinside.com 2019 - 2024. All rights reserved.