Tomcat 7“严重:子容器在启动期间失败”

Posted

技术标签:

【中文标题】Tomcat 7“严重:子容器在启动期间失败”【英文标题】:Tomcat 7 "SEVERE: A child container failed during start" 【发布时间】:2012-05-09 12:38:21 【问题描述】:

基本上,我已经编写了一个springMVC 应用程序(在 Spring 方面,我使用了一种相对较新的方法)。该项目在 Tomcat 6 上运行良好。我的 Tomcat 服务器未启动并引发以下异常:

Apr 29, 2012 3:41:00 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/bin/jdk1.7.0_03/jre/lib/amd64/server:/usr/bin/jdk1.7.0_03/jre/lib/amd64:/usr/bin/jdk1.7.0_03/jre/../lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]Server/Service/Engine/Host/Context Setting property 'source' to 'org.eclipse.jst.j2ee.server:spring-security-integration' did not find a matching property.
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]Server/Service/Engine/Host/Context Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3Hibernate' did not find a matching property.
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]Server/Service/Engine/Host/Context Setting property 'source' to 'org.eclipse.jst.jee.server:assessment' did not find a matching property.
Apr 29, 2012 3:41:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 29, 2012 3:41:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 29, 2012 3:41:00 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 654 ms
Apr 29, 2012 3:41:00 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 29, 2012 3:41:00 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Apr 29, 2012 3:41:01 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sun Apr 29 15:41:01 BST 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3dd5df15: defining beans []; root of factory hierarchy
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 226 ms
Apr 29, 2012 3:41:01 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Sun Apr 29 15:41:01 BST 2012]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@cf10596: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,dataSource,sessionFactory,homeController,userManagementController,userService,userDao,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@3dd5df15
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public java.lang.String org.assessme.com.controller.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "[/userManagement/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public java.lang.Object org.assessme.com.controller.UserManagementController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "[/userManagement/getUser],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]" onto public org.assessme.com.entity.User org.assessme.com.controller.UserManagementController.data(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 1846 ms
Apr 29, 2012 3:41:03 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Spring3Hibernate]]
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1128)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:782)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Spring3Hibernate]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 7 more
Caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60
    at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
    at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:60)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2032)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1923)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1891)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1877)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more

我真的不确定这是指什么,我很乐意展示任何代码等,但我真的不知道它指的是什么。下面是我的 pom.xml,以防万一。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.assessme</groupId>
    <artifactId>com</artifactId>
    <name>assessme</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.0.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.9</org.aspectj-version>
        <org.slf4j-version>1.5.10</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>$org.springframework-version</version>
            <exclusions>

                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>$org.springframework-version</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>$org.springframework-version</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>$org.aspectj-version</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>$org.slf4j-version</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>$org.slf4j-version</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>$org.slf4j-version</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Persistence -->

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>$org.springframework-version</version>
        </dependency>


        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.5.6-Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.11.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>$org.springframework-version</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.18</version>
        </dependency>


        <!-- Jackson JSON Mapper -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.5</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

有人有什么想法吗?

【问题讨论】:

【参考方案1】:

当 servlet 3.0 应用程序启动时,容器必须扫描所有类的注释(除非 metadata-complete=true)。 Tomcat 使用 Apache Commons BCEL 的一个分支(没有添加,只是删除了未使用的代码)来执行此扫描。 Web 应用无法启动,因为 BCEL 遇到了它无法理解的问题。

如果应用程序在 Tomcat 6 上运行良好,则在 web.xml 中添加 metadata-complete="true" 或在 web.xml 中将应用程序声明为 2.5 应用程序将停止注释扫描。

目前,这看起来像是正在扫描的课程中的一个问题。但是,直到我们知道是哪个类导致了问题并仔细研究之前,我们不会知道。我需要修改 Tomcat 以记录更有用的错误消息,该错误消息会命名相关类。您可以在以下位置关注这一点的进展: https://issues.apache.org/bugzilla/show_bug.cgi?id=53161

【讨论】:

我正在使用 Tomcat 9 但我仍然收到此错误,我已经尝试了您重新启动的修复但它不起作用,还有什么我可以尝试的吗? 同上。 Tomcat 9 仍然出现此错误。但我有两个问题:[1] 如何在 web.xml 中添加 metadata-complete = "true" - 这是 servlet 的参数名称和值对吗? [2] 即使这与 web.xml 一起工作,如何为 Maven 项目解决这个问题?我那里没有任何 web.xml。【参考方案2】:

您可以使用以下方法修复它:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>$servlet-api-version</version>
    <scope>provided</scope>
</dependency>

提供解决了这个问题

【讨论】:

对我来说,它在没有“提供”的情况下一直有效。今天,它突然停止工作,我遇到了这个解决方案,令人惊讶的是,它有效。我仍在试图弄清楚发生了什么。 对我来说,它一直与(是的)“提供”一起使用。今天,它突然停止工作。我在 Tomcat 7.0.52 上,我看不到我的任何班级造成麻烦。我从 Maven 运行它: mvn clean install tomcat7:run -DskipTests 通过使用 .war 存档的副本在 Tomcat 上手动部署,我可以看到我的错误类。解决了。​​ 不赞成 bc,首先,scope=provided 不能解决问题。其次,您还没有解释为什么这应该起作用。请不要在没有任何解释的情况下随意复制粘贴代码。 @erhun - 它帮助了我,所以我认为这是有道理的。【参考方案3】:

不要惊慌。您是否复制了 servlet 代码?好的,

@WebServlet("/HelloWord")
public class HelloWorld extends HttpServlet 
private static final long serialVersionUID = 1L;

您为两个名称不同的 servlet 提供了相同的路径 @WebServlet("/HelloWord")

如果您创建了web.xml 文件,请检查classpath

【讨论】:

【参考方案4】:

几个月前我也遇到了同样的问题。这解决了我使用 Maven 而不是下载的 Spring 版本以及 web.xml 中的一些更改的问题。

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SpringWEB1</groupId>
  <artifactId>SpringWEB1</artifactId>
  <version>1</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
  </dependencies>
</project>

Controller.java

package com.jmtm.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@org.springframework.stereotype.Controller
public class Controller 

    @RequestMapping("/hi")
    public ModelAndView hi()
        return new ModelAndView("Hello", "msg", "Hello user.");
    


spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd">

    <context:component-scan base-package="com.jmtm.controller"></context:component-scan>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>

解决方案中最重要的部分,在 web.xml 中包含 servlet 调度程序(A.K.A. spring-servlet.xml)的路径

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>SpringWEB1</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

当我尝试解决这个问题时,发生了一些奇怪的事情。任何从maven.springframework.org/release/org/springframework/spring 下载的 Spring 版本都会给我带来很多问题(Tomcat 找不到 servlet,Spring 停止 Tomcat,Eclipse 无法启动服务器 weird),所以有很多问题可以找到许多部分解决方案。我希望这对你有用。

作为额外帮助,在 Eclipse 中,从 Eclipse Marketplace 下载 Spring STS Tool for Eclipse,这将帮助您创建配置文件 (servlet.xml) 并在 web.xml 文件中为 servlet 编写代码。

【讨论】:

【参考方案5】:

您使用的 servlet api 版本似乎比您在 web.xml 中使用的 xsd 旧,例如 3.0

使用这个 ****http://java.sun.com/xml/ns/javaee/" id="WebApp_ID" version="2.5"> ****

【讨论】:

【参考方案6】:

Tomcat 服务器无法启动并引发异常,因为在Deployment Descriptor:MyProyect / Servlet Mappings 部分内有不存在的映射。删除或更正这些元素;然后启动服务器没有问题。

【讨论】:

【参考方案7】:

我有同样的问题,但在我的情况下,我错误地在 server.xml ($Tomcat_Install_Dir/conf/) 中添加了一个上下文,并且没有在 webapps($Tomcat_Install_Dir 中部署相应的战争/webapps)。当我删除该上下文并重新启动 tomcat 时,它工作正常。

【讨论】:

【参考方案8】:

如果您认为以前它运行正常,现在它开始显示特定问题。那么它只是一个打击和尝试的方法来解决。因此,为了获得更好的解决方案,您可以按照以下步骤操作

    如果可能,请删除现有的 tomcat 删除您的项目并使用新版本添加您的项目 添加您的 tomcat 服务器 清理项目并刷新项目 进入运行或调试模式

【讨论】:

【参考方案9】:

我最近将所有 Eclipse 项目都转移到了新 PC 上。我遇到了这个问题。我所做的是:

    从 tomcat 中删除了项目 干净的tomcat 在tomcat中运行项目

【讨论】:

【参考方案10】:

这通常是 web.xml 描述符文件的问题。可能是您混淆了注释和 web.xml servlet 描述定义。请查看控制台以获取更多信息。

【讨论】:

这正是发生在我身上的事!我在 web.xml 中定义了 servlet,并通过 @WebServlet 注释【参考方案11】:

对我来说,一种情况是我错过了导致同样问题的 maven 更新项目

maven 更新项目,如果您在 POM.xml 中看到任何错误,请尝试

【讨论】:

【参考方案12】:

我和堆栈跟踪也发生了同样的问题

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/XXXXSearch]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/XXXXSearch]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/XXXXSearch]. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2109)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1981)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1947)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1932)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1326)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.lang.***Error
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)

我分析发现,这个问题是在Tomcat启动注解处理导致非法循环继承依赖时出现的。

但是我的项目有很多依赖JAR,找不到负责这个的。

在尝试了这么多不愉快的方法之后,我所做的是,我更新了我的 tomcat 插件以跟随并运行相同的场景,

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat8-maven-plugin</artifactId>
    <version>3.0-r1756463</version>
<\plugin>

然后我能够找到导致此问题的 JAR,

Aug 23, 2017 2:32:12 PM org.apache.catalina.startup.ContextConfig processAnnotationsJar
SEVERE: Unable to process Jar entry [cryptix/test/TestLOKI91.class] from Jar [jar:file:/C:/Users/Tharinda/.m2/repository/cryptix/cryptix/1.2.2/cryptix-1.2.2.jar!/] for annotations
java.io.EOFException
    at org.apache.tomcat.util.bcel.classfile.FastDataInputStream.readUnsignedShort(FastDataInputStream.java:120)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readAttributes(ClassParser.java:110)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:94)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1994)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1944)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1919)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1880)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1149)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5120)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

然后用 cryptix-1.2.2.jar 解决这个问题就解决了这个问题。

我强烈建议移动目前看起来稳定且错误较少的 tomcat8-maven-plugin

【讨论】:

【参考方案13】:

这是我长期以来一直面临的。

上次发生这种情况,并发现一种情况可能是糟糕的战争部署,这是在我更新 pom 上的库/maven 依赖项并重新安装它之后发生的。

解决方案:

right click on the server >  remove the war and 
right click on the server again > clean
make sure the maven dependencies are added to deployment assembly
right click on the project > Run As > maven clean
right click on the project again > Run As > maven install 
and finally deploy the project on to the server. This helped me to solve the issue  

【讨论】:

【参考方案14】:

“tomcat没有问题”。

我已经经历了 4-5 天的时间来解决这个问题(上面提到的同样的问题)。这里我使用的是tomcat 8.5。最后,问题得到解决,问题在于“损坏的 jar 文件”。您必须删除所有 .m2 存储库(对我来说是 C:\Users\Bandham.m2\repository)。 den 从您的项目文件夹中运行“mvn clean install”命令。

编码愉快。

如果它解决了你的问题,请放弃。

【讨论】:

【参考方案15】:

作为一个通用的解决方案,我建议您删除所有辅助依赖项并运行应用程序,如果它有效,请还原一些,并在应用程序启动时继续执行相同操作,最后,您将能够找出导致问题的依赖项。

用同样的方法,比如我发现groupId为:org.apache.axis2的依赖导致了这个问题。

 <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-local</artifactId>
        <version>1.6.1</version>
 </dependency>
 <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-http</artifactId>
        <version>1.6.1</version>
 </dependency>

【讨论】:

【参考方案16】:

我遇到过类似的问题,但它可以像编码问题一样解决错误。 更改IDE编码后,它工作正常。

【讨论】:

【参考方案17】:

我在tomcat启动时看到了这个异常,几乎花了好几个小时才弄清楚原因。最后我发现除了 Maven 依赖项中的 Spring jar 之外,lib 文件夹中还有一些较低版本的 Spring JAR。当我添加一个新的 Spring Rest 控制器时,Eclipse 会自动添加 lib 中的 JAR。 我从 lib 文件夹中删除了这些,然后让 Maven 处理 JAR/依赖项,这很好。 底线是如果由 Maven 管理的 JARS 和 WEB-INF/lib 中的 jar 导致类路径问题,您可能会遇到此错误。

【讨论】:

欢迎来到 *** 并感谢您的帮助 - 但您已经注意到这个问题已有 8 年历史了?【参考方案18】:

我通过将web.xml 声明更新为 Servlet 4.0 规范解决了类似的问题,如下所示(我使用的是 Tomcat 9):

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                          http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
      version="4.0"
      metadata-complete="true">
      <!-- ... (your content here) ... -->
</web-app>

您可以参考Tomcat的which version page上的图表查看Tomcat支持的servlet版本。

【讨论】:

【参考方案19】:

如果你新添加了tomcat。可能是某些旧版本的依赖项可能无法被 tomcat 扫描。只需获取最新版本并在您的项目中使用它。对我来说,我添加了新版本的 javax.annotation 并且它可以工作

【讨论】:

以上是关于Tomcat 7“严重:子容器在启动期间失败”的主要内容,如果未能解决你的问题,请参考以下文章

并行类加载——让tomcat玩转双十一 @双十一实战

Docker:在 Tomcat 镜像构建期间访问 MySQL 容器

Tomcat/Eclipse:在上下文重新加载期间禁用 HttpSession 序列化

Tomcat关闭:contextDestroyed期间的类加载不起作用

Tomcat 6.0.28 由于浸泡测试期间线程阻塞而无响应

Spring Boot在部署到Tomcat期间无法加载外部jar