2012-04-29 95 views
29

基本上,我已經編寫了一個springMVC應用程序(對於Spring而言,我的方式相對於獵槍來說是第一次使用的方法)。該項目工作正常在Tomcat 6,我的Tomcat服務器無法啓動,並拋出以下異常:Tomcat 7「SEVERE:子容器在啓動過程中失敗」

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.s[email protected]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.s[email protected]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.s[email protected]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> 

有沒有人有任何想法?

回答

25

當servlet 3.0應用程序啓動時,容器必須掃描所有類的註釋(除非metadata-complete = true)。 Tomcat使用Apache Commons BCEL的一個分支(沒有增加,只是未使用的代碼)來執行此掃描。網絡應用程序無法啓動,因爲BCEL遇到了不理解的內容。

如果應用程序在Tomcat 6上運行良好,則在web.xml中添加metadata-complete =「true」或在web.xml中將應用程序聲明爲2.5應用程序將停止註釋掃描。

目前,這看起來像是正在掃描的課程中的一個問題。然而,直到我們知道哪個班級導致問題並仔細觀察,我們纔會知道。我需要修改Tomcat來記錄一個更有用的錯誤消息,用來命名有問題的類。您可以按照在這一點上取得進展: https://issues.apache.org/bugzilla/show_bug.cgi?id=53161

20

你可以解決它:

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

提供解決了這個問題

+0

對我來說,它一直沒有「提供」。今天,它突然停止工作,我遇到了這個解決方案,而且令人驚訝的是,它工作。我仍然在試圖弄清楚發生了什麼事情。 – 2014-09-08 20:03:41

+0

對我來說,它一直與(與)與「提供」。今天,突然它停止工作。我在Tomcat 7.0.52上,我看不到任何類別的問題。我從Maven運行它:mvn clean install tomcat7:運行-DskipTests – Stephane 2014-09-21 05:53:55

+0

通過在.war文件的副本上手動部署Tomcat,我可以看到我的錯誤類。解決了。 – Stephane 2014-09-21 06:53:15

0

不要驚慌。你有沒有複製servlet代碼?好吧,

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

對於兩個名稱不同的servlet,您都給出了相同的路徑@WebServlet("/HelloWord")

如果您創建了一個web.xml文件,然後檢查classpath

0

幾個月前我有同樣的問題。這使用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調度器(AKA 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無法啓動服務器{很怪異}),所以很多問題找到了許多部分解決方案。我希望這對你有用。

作爲額外的幫助,在Eclipse中,從Eclipse Marketplace下載Spring STS Tool for Eclipse,這將幫助您創建配置文件(servlet.xml)並在web.xml文件中爲Servlet編寫代碼。

0

這似乎像你使用Servlet API的版本比您正在使用在web.xml如3.0

使用這一個 **** HTTP的XSD以上://java.sun.com/XML/NS/JavaEE的/」 ID = 「WebApp_ID」 版本= 「2.5」> ****

0

Tomcat服務器無法啓動,並拋出異常,因爲板塊內Deployment Descriptor:MyProyect/Servlet Mappings有映射的是鴕鳥政策刪除或更正這些元素;然後啓動服務器工作沒有問題

0

我有同樣的問題b ut在我的情況錯誤我在server.xml($ Tomcat_Install_Dir/conf /)添加一個上下文,並沒有在webapps($ Tomcat_Install_Dir/webapps)部署相應的戰爭。當我刪除該上下文並重新啓動tomcat它工作正常。

2

如果你正在考慮以前它是正確的,現在運行在其上開始出現的具體問題。那麼這只是一個解決問題的熱門和試用方法。所以要得到更好的解決方案,你可以按照以下步驟

  1. 刪除現有的tomcat,如果可能的話
  2. 刪除您的項目,並用新的構建
  3. 添加項目中添加Tomcat服務器
  4. 清潔工程並刷新該項目
  5. 去運行或調試模式
5

我最近搬到新的PC我所有的Eclipse項目。我遇到過這個問題。我所做的是:

  1. 從Tomcat
  2. 乾淨的tomcat
  3. 運行項目在Tomcat中
1

刪除項目這通常是與web.xml描述文件的問題。可能是你混淆了註釋和web.xml servlet描述定義。請檢查控制檯以獲取更多信息。

+0

這正是我發生的事情!我在web.xml中通過@WebServlet註釋定義了servlet – Pavel 2018-02-13 15:29:57

0

我一個案件我只是錯過了Maven的更新項目,這導致了同樣的問題

行家更新項目和嘗試,如果你在pom.xml中看到任何錯誤發生,我

0

這個同樣的問題,堆棧跟蹤

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.StackOverflowError 
    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目前看起來穩定且缺少錯誤。

相關問題