gpt4 book ai didi

Tomcat 10.x 在 javax/servlet/ServletRequestListener 上抛出 java.lang.NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-04 11:17:26 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Servlet 5.0 JAR throws compile error on javax.servlet.* but Servlet 4.0 JAR does not

(2 个回答)


6 个月前关闭。




在上下文路径 [/VirtualStore] 上部署了基于 servlet 的 Web 应用程序,但上下文无法从以下日志开始。

19-Mar-2021 11:46:35.075 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VS.xml] has finished in [448] ms
19-Mar-2021 11:46:35.079 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\docs]
19-Mar-2021 11:46:35.291 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [143] milliseconds.
19-Mar-2021 11:46:35.306 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\docs] has finished in [228] ms
19-Mar-2021 11:46:35.307 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\examples]
19-Mar-2021 11:46:35.613 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\examples] has finished in [307] ms
19-Mar-2021 11:46:35.613 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\host-manager]
19-Mar-2021 11:46:35.646 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\host-manager] has finished in [32] ms
19-Mar-2021 11:46:35.646 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\manager]
19-Mar-2021 11:46:35.676 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\manager] has finished in [29] ms
19-Mar-2021 11:46:35.676 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\ROOT]
19-Mar-2021 11:46:35.703 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\webapps\ROOT] has finished in [27] ms
19-Mar-2021 11:46:35.708 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8085"]
19-Mar-2021 11:46:35.726 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1894] milliseconds
19-Mar-2021 11:46:36.546 INFO [http-nio-8085-exec-9] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/VirtualStore]
19-Mar-2021 11:46:36.562 INFO [http-nio-8085-exec-4] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VirtualStore.xml]
19-Mar-2021 11:46:36.563 WARNING [http-nio-8085-exec-4] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/VirtualStore] in deployment descriptor [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VirtualStore.xml] has been ignored
19-Mar-2021 11:46:36.934 SEVERE [http-nio-8085-exec-4] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying deployment descriptor [C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VirtualStore.xml]
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:743)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:692)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:540)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1777)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:288)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1570)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:1022)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:357)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:663)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:668)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:378)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:56)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:870)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1696)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/VirtualStore]]
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)
... 44 more
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2470)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:866)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1370)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1224)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:540)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:521)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1086)
at org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:664)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:92)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5115)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 45 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletRequestListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1401)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1224)
... 60 more
这是怎么引起的,我该如何解决?

最佳答案

C:\Users\Ing.Girbson BIJOU\Documents\NetBeansProjects\apache-tomcat-10.0.4-windows-x64\apache-tomcat-10.0.4\conf\Catalina\localhost\VirtualStore.xml


因此,您使用的是基于 Servlet API 5.0 版的 Tomcat 10.x,而后者又是 Jakarta EE 9 版的一部分。

java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener


这是出乎意料的。 javax.*包已重命名为 jakarta.*包自 Jakarta EE 版本 9。这意味着部署的 Web 应用程序实际上与 Jakarta EE 版本 9 不兼容。部署的 Web 应用程序很可能是为较旧的 JEE 版本开发的,其中 javax.*包还在用。
因此,总而言之,目标 JEE 版本不匹配,这给您带来了麻烦。您有 2 个选择:
  • 将 Tomcat 降级到 9.x 版。这是仍然使用 javax.* 的最新可用版本包裹。
  • 或者,将部署的 Web 应用程序升级到目标 Jakarta EE 9。 IE。调整项目的依赖项(例如 pom.xml )以引用基于 JEE 9+ 的版本,并在项目范围内执行 javax.* 的查找和替换至 jakarta.* (当然除了 javax.naming.*javax.xml.* 以及其他一些,但 Java 编译器会很快为您指出它们)。

  • 也可以看看:
  • Apache Tomcat - Versions
  • Tomcat 9 casting servlets to javax.servlet.Servlet instead of jakarta.servlet.http.HttpServlet (此答案包含 Tomcat 10+、Tomcat 9-、JEE 9+ 和 JEE 8- 的正确 pom.xml 声明的完整示例)。
  • 关于Tomcat 10.x 在 javax/servlet/ServletRequestListener 上抛出 java.lang.NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66711660/

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