英文:
Tomcat 9 JDK 14 "java.lang.NoClassDefFoundError: javax/xml/ws/WebServiceRef"
问题
你好,以下是翻译好的部分:
我有一个使用Netbeans 12和Tomcat 9正常工作的Java Web应用程序。然而,最近我将JDK从1.8.0更新到了14.0.2,现在每次尝试运行项目时都会遇到以下错误:
java.lang.NoClassDefFoundError: javax/xml/ws/WebServiceRef
...
我已经尝试将javax.xml.ws添加到我的pom文件,但没有成功:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
我还尝试了以下方法,但都没有成功:
- 在我的pom中使用jakarta版本而不是javax版本
- 将jaxws-api jar文件添加到Tomcat的lib文件夹
- 切换到JDK 9、10、11、13
- 切换到Tomcat 8.5、10
我甚至可以在我的代码中导入/引用WebServiceRef类而不会出现编译错误,所以我知道它在那里。为什么会出现这个错误,我该如何修复它?
如果需要更多详细信息,请告诉我。
编辑:
我认为错误出现在启动Tomcat时,而不是运行我的项目时。我的项目可以正常构建 - 只有在部署时才会出现错误。我已经下载了Tomcat的源代码,并确实看到了对WebServiceRef类的使用。我认为由于javax.xml.ws不再包含在JDK 9+中,Tomcat的代码会引发错误。我只是不知道如何添加Tomcat要使用的库 - 将它添加到lib文件夹中没有起作用。
英文:
I have a java web app that has been working normally with Netbeans 12 and Tomcat 9. However, I recently updated my JDK from 1.8.0 to 14.0.2 and now I get this error every time I try to run the project:
27-Jul-2020 23:29:47.565 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [Tomcat WebSocket (JSR356) Filter]
java.lang.NoClassDefFoundError: javax/xml/ws/WebServiceRef
at org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(DefaultInstanceManager.java:303)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:135)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:111)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4481)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5121)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:740)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:716)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:620)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1644)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
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:1479)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:900)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:592)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:319)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:88)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:625)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1372)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:832)
I've added javax.xml.ws to my pom file with no luck:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
I have also tried without success:
- Using the jakarta version instead of javax in my pom
- Adding the jaxws-api jar to Tomcat's lib folder
- Switching to JDK 9, 10, 11, 13
- Switching to Tomcat 8.5, 10
I can even import/reference the WebServiceRef class in my code without a compile error, so I know it's there. Why am I getting this error/how do I fix it?
I can post more details if needed.
EDIT:
I believe the error is in starting Tomcat and not in running my project. My project is able to build without error - it's only when it's being deployed that I get the error. I've downloaded the source for Tomcat and can indeed see the use of the WebServiceRef class. My thought is that since javax.xml.ws is no longer included in JDK 9+, Tomcat's code is throwing an error. I just don't know how to add the library for Tomcat to use - adding it to the lib folder didn't work.
答案1
得分: 1
我最终通过将以下JAR文件添加到Tomcat的lib文件夹中(JAX WS API及其所有依赖项)来解决了这个问题:
- jaxws-api-2.3.1
- jaxb-api-2.3.1
- javax.xml.soap-api-1.4.0
- javax.annotation-api-1.3.2
- java.activation-api-1.2.0
英文:
I was finally able to resolve this by adding the following JARs to Tomcat's lib folder (JAX WS API and all its dependencies):
- jaxws-api-2.3.1
- jaxb-api-2.3.1
- javax.xml.soap-api-1.4.0
- javax.annotation-api-1.3.2
- java.activation-api-1.2.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论