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.(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.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.bootgroupId>
                    <artifactId>spring-boot-starter-tomcatartifactId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-tomcatartifactId>
            <scope>providedscope>
        dependency>

重新打包、部署即可。

 

转载于:https://www.cnblogs.com/GreenMountain/p/11254006.html

你可能感兴趣的:(Tomcat启动报错:java.lang.NoClassDefFoundError: javax/servlet/GenericFilter)