当前位置: 首页 > 知识库问答 >
问题:

Tomcat 10.x在javax.servlet.*上抛出java.lang.NoClassDefFoundError[duplicate]

艾焕
2023-03-14

在上下文路径[/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

这是如何造成的,我该如何解决?

共有1个答案

宿建本
2023-03-14

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的Tomcat10.x,而Servlet API版本5.0又是Jakarta EE版本9的一部分。

java.lang.noClassDefFoundError:javax/servlet/servletRequestListener

因此,概括地说,目标JEE版本不匹配,这给您带来了麻烦。您有两种选择:

>

  • 将Tomcat降级到9.x版本。这是最新的可用版本,仍然使用javax.*包。

    或者,将部署的web应用程序升级为目标Jakarta EE9。即。调整项目的依赖项(例如pom.xml)以引用基于JEE9+的版本,并在项目范围内执行javax.*jakarta.*的查找和替换(当然,除了javax.naming.*javax.xml.*以及其他几个,但是Java编译器会很快为您指出它们)。

      null

  •  类似资料:
    • 我正在尝试从命令行编译和部署一个简单的web应用程序。 Apache Tomcat的servlet-api.jar没有编译我的Java文件,但是maven中央存储库的javax.servlet-api-4.0.1成功地编译了它。即便如此,当我部署应用程序并尝试在浏览器中使用它时,我还是会得到一个错误。 我正在使用: javac 11.0.8 Apache Tomcat 10.0(servlet-a

    • 我正在努力学习ANTLR4,并遵循ANTLR4权威参考中给出的示例。可悲的是,我被第一个例子卡住了。 系统: Windows 10(1703) Java 8,更新151 ANTLR 4,V4.7 我的问题是: 当我对示例语法()运行时,我会得到以下错误消息 对我做错了什么有什么想法吗? 非常感谢! 编辑: 我以为我找到了答案。通过-ing到编译文件所在的文件夹(而不是从根项目文件夹调用),我设法完

    • 问题内容: 每次我运行该程序时,都会出现以下错误: 每当有人被螺栓击中时,我都试图降低其健康状况。如果一个外星人的健康状况良好,也应该予以销毁。同样,螺栓也会被破坏。这是我的代码: 在上线情况。为了澄清,和都是字典列表。 我究竟做错了什么? 问题答案: 您不应从正在循环的列表中删除项目。而是创建一个副本: 和 循环访问列表时修改列表会影响循环: 从要遍历两次的列表中删除项目会使事情变得更加复杂,从

    • 问题内容: 阅读的JavaDoc ,我碰到了一个奇怪的方法签名;我一生中从未见过: 乍一看,我想知道通用异常怎么可能发生,因为您不能这样做(here和here)。再三考虑,这开始变得有意义,因为这里只是绑定…,但是供应商本身确切知道泛型之前应该是什么类型。 但是第二行打给我: 是完整的通用异常类型。 然后: 什么世界呢 这 是什么意思? 已绑定在方法签名中。 这将以任何方式解决通用异常限制吗? 为

    • 我正在从这里运行以下命令 该包正在成功编译。 但是当我跑步的时候 它给出了以下错误 错误:无法初始化主类com . github . coat . app 原因:java.lang.NoClassDefFoundError: boofcv/gui/image/ImageBoard 我是不是编译错了? 编辑:我没有使用Eclipse 更新:https://stackoverflow.com/a/52

    • 两者的最后一个调用,即检索特定SomeDto对象的调用,可以抛出ResourceNotFoundException,该调用被配置为返回ResponseStatus NOT_Found: 但是,当调用此“未安全”时,它不会返回404 HTTP状态--它会返回401未授权: 但是,当我在RestController中显式捕获异常并将HttpServletResponse对象上的响应状态设置为 当我用一