zoukankan      html  css  js  c++  java
  • Tomcat启动报错:java.lang.NoClassDefFoundError: javax/servlet/GenericFilter

    Jul 27, 2019 9:24:30 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive /opt/tomcat_api/webapps/uniapi.war
    Jul 27, 2019 9:24:30 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
    INFO: validateJarFile(/opt/tomcat_api/webapps/uniapi/WEB-INF/lib/tomcat-embed-core-9.0.16.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
    Jul 27, 2019 9:24:30 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
    INFO: validateJarFile(/opt/tomcat_api/webapps/uniapi/WEB-INF/lib/tomcat-embed-el-9.0.16.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
    Jul 27, 2019 9:24:30 AM org.apache.catalina.deploy.WebXml setVersion
    WARNING: Unknown version string [4.0]. Default version will be used.
    Jul 27, 2019 9:24:31 AM org.apache.catalina.startup.TldConfig execute
    INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    Jul 27, 2019 9:24:31 AM org.apache.catalina.core.ContainerBase addChildInternal
    SEVERE: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/uniapi]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.NoClassDefFoundError: javax/servlet/GenericFilter
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3205)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1373)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1861)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
        at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:109)
        at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
        at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5622)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        ... 10 more
    Caused by: java.lang.ClassNotFoundException: javax.servlet.GenericFilter
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
        ... 22 more

    在测试环境部署服务,启动Tomcat时提示以上错误。网上搜索,发现是springboot框架自带的tomcat包与实际运行的tomcat有冲突导致的。在pom文件中修改如下:

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-tomcat</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>

    重新打包、部署即可。

  • 相关阅读:
    关于python的类成员方法允许静态调用的机制
    一个pyqt5动态加载ui+多线程+信号刷新界面的例子
    一个经典的redis队列简单解决方案
    关于连表查询的执行计划
    electron nativefier打包网址 electron-winstaller制作安装包
    MySQL 8.0 字符串比较特殊案例小结
    MySQL SELECT_LEX与subselect 执行 源码阅读笔记
    MySQL 8.0 QueryResolver 源码笔记
    MySQL 8.0 Optimizer 源码笔记
    MySQL Item 源码阅读笔记
  • 原文地址:https://www.cnblogs.com/GreenMountain/p/11254006.html
Copyright © 2011-2022 走看看