8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

Tomcat 10.x 在 javax.servlet 上抛出 java.lang.NoClassDefFoundError。*

adw 1月前

83 0

在上下文路径 [/VirtualStore] 上部署了基于 servlet 的 Web 应用程序,但上下文无法从以下日志启动。2021 年 3 月 19 日 11:46:35.075 INFO [main] org.apache.catalina.startup.HostConfig。

在上下文路径 [/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、本帖标题:Tomcat 10.x 在 javax.servlet 上抛出 java.lang.NoClassDefFoundError。*
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由adw在本站《maven》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 当然可以 @PiotrP.Karwasz 。谢谢。我发现一个已经打开了 - .com/questions/78550035/…

  • @piotr-p-karwasz 和其他人:有人知道如何将此 Loader 级别更改应用于 Spring boot 3.0.x 的嵌入式 Tomcat 吗?

  • 我正在使用带有 spring 5.3.23 的 tomcat 10.0.27。我将其添加到 conf/context.xml 中。它运行良好。

  • 由于我的安装没有“VirtualStore.xml”,我只需将 Loader 行添加到 Tomcat 安装的 context.xml 中,重新启动即可。

  • 虽然最干净的解决方案是 BalusC 提供的解决方案(即始终将应用程序部署在设计运行的平台上),但自 Tomcat 10.0.4 以来,有一种解决方法允许在 Tomcat 10 上部署 Servlet 4.0 应用程序。

    您只需要修改您的上下文描述 conf\Catalina\localhost\[contextname].xml (在您的情况下 [contextname] VirtualStore )并添加:

    <Context>
        ...
        <Loader jakartaConverter="TOMCAT" />
    </Context>
    

    (参见 Tomcat 文档 )。

    这将即时转换(简单的)Servlet 4.0 应用程序,作为 Jakarta EE 的 Tomcat 迁移工具 .

  • 当我将 Spring Boot Web 应用程序从 Boot 3 降级到 Boot 2.7 时,就发生了这种情况

  • 更新项目后,我还必须在 Eclipse 中删除并重新创建服务器,我不知道为什么。但现在看起来没问题。

  • 根据您的日志,

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

    然而,这个异常是意料之外的:

    java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener

    基本上,已部署的 Web 应用程序正在寻找 javax.servlet.* ,但实际上应该寻找 jakarta.servlet.* 。也就是说, javax.* ,包已重命名为 jakarta.* 包。这意味着已部署的 Web 应用程序实际上与 Jakarta EE 版本 9 不兼容。已部署的 Web 应用程序很可能是为较旧的 JEE 版本开发的,其中 javax.* 仍使用该包。

    因此,总结一下,目标 JEE 版本不匹配,这会给您带来麻烦。您有 2 个选择:

    1. p6

    2. p7

    参见:

  • Tomcat 可以在部署时使用适用于 Jakarta EE 的 Apache Tomcat 迁移工具将现有 Web 应用程序从 Java EE 8 转换为 Jakarta EE 9。要使用该功能,应将 Web 应用程序放在主机 legacyAppBase 文件夹中(默认名为 webapps-javaee),然后它们将转换为主机 appBase 文件夹中的等效 Jakarta EE Web 应用程序(默认名为 webapps)。

返回
作者最近主题: