gpt4 book ai didi

java - ClassNotFoundException : javax. jws.WebService

转载 作者:行者123 更新时间:2023-12-05 06:19:11 32 4
gpt4 key购买 nike

我正在尝试将一个简单的 java servlet 部署到 Tomcat,它使用部署到本地主机上同一个 Tomcat 的 Web 服务。我正在 Netbeans 中处理 Maven 项目。

servlet 导入以下类:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceRef;

我能够将生成的 war 文件部署到 Tomcat,但我无法启动应用程序,catalina.out 中出现以下错误:

    28-Mar-2020 20:57:12.769 SEVERE [http-nio-8080-exec-93] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/opt/tomcat/apache-tomcat-9.0.31/webapps/CalculatorWebServiceClient.war]
java.lang.IllegalStateException: Error starting child
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1642)
at jdk.internal.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1590)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:294)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
...
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CalculatorWebServiceClient]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
... 43 more
Caused by: java.lang.TypeNotPresentException: Type javax.jws.WebService not present
at java.base/sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:86)
at com.sun.proxy.$Proxy2.value(Unknown Source)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1699)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1137)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5051)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 44 more
Caused by: java.lang.ClassNotFoundException: javax.jws.WebService
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)

我注意到日志文件中的 ClassNotFoundException: javax.jws.WebService 并编辑了 pom.xml 文件以包括:

javax.xml.ws.jaxws-api.2.3.1 及其根据 [ https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api/2.3.1/][1] 找到的编译依赖项:

javax.annotation.javax.annotation-api.1.3.2
javax.xml.bind.jaxb-api.2.3.1
javax.xml.soap.javax.xml.soap-api.1.4.0

检查项目目录时,我可以看到相应的库存在于 WEB-INF/lib 目录中。

即使在这之后我仍然收到相同的错误消息并且无法启动应用程序。有人可以告诉我我在这里缺少什么吗?

亲切的问候,迈克尔

最佳答案

我遇到了同样的问题,将 IDE 使用的 Java 版本从 11 更改为 8,并将我的 Maven 设置为 3.3.9,“ClassNotFoundException: javax.jws.WebService”问题为我解决了。

关于java - ClassNotFoundException : javax. jws.WebService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60906948/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com