2013-06-21 106 views
1

我有一個簡單的(REST)的Web應用程序會拋出以下錯誤,當我運行mvn tomcat7:運行, 在那裏,因爲它正常工作與MVN tomcat7:運行 - 戰爭而已。tomcat7:運行失敗,其中作爲tomcat7:運行戰爭只能

[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Could not start Tomcat 

Embedded error: Failed to start component [StandardServer[-1]] 
A child container failed during start 
[INFO] ------------------------------------------------------------------------ 
[INFO] Trace 
org.apache.maven.lifecycle.LifecycleExecutionException: Could not start Tomcat 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) 
     at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:597) 
     at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 
     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 
     at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 
     at org.codehaus.classworlds.Launcher.main(Launcher.java:375) 
Caused by: org.apache.maven.plugin.MojoExecutionException: Could not start Tomcat 
     at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:486) 
     at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) 
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) 
     ... 17 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]] 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
     at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335) 
     at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.startContainer(AbstractRunMojo.java:1018) 
     at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:478) 
     ... 19 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]] 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
     at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     ... 22 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]] 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
     at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     ... 24 more 
Caused by: org.apache.catalina.LifecycleException: A child container failed during start 
     at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131) 
     at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     ... 26 more 

下面是pom.xml的Tomcat配置,

<plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <configuration> 
     <contextFile>${basedir}/src/test/resources/context.xml</contextFile> 
     <useTestClasspath>true</useTestClasspath> 
     <systemProperties> 
      <systemProperty> 
       <name>maven.tomcat.port</name> 
       <value>8090</value> 
      </systemProperty> 
     </systemProperties> 
    </configuration> 
    <version>2.0</version> 
    <executions> 
     <execution> 
      <id>tomcat7-run</id> 
      <goals> 
       <goal>run-war-only</goal> 
      </goals> 
      <phase>pre-integration-test</phase> 
      <configuration> 
       <fork>true</fork> 
       <port>8090</port> 
      </configuration> 
     </execution> 
     <execution> 
      <id>tomcat-shutdown</id> 
      <goals> 
        <goal>shutdown</goal> 
      </goals> 
      <phase>post-integration-test</phase> 
      <configuration> 
       <fork>true</fork> 
       <port>8090</port> 
      </configuration> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <groupId>org.apache.xbean</groupId> 
      <artifactId>xbean-spring</artifactId> 
      <version>3.4.3</version> 
      <scope>compile</scope> 
     </dependency> 
    </dependencies> 
</plugin> 

如何解決這個這個問題還是如何將這種進一步調試任何幫助將不勝感激。

感謝和問候, Shrey

回答

1

在我的情況發生,因爲servlet-api依賴從碼頭過來。從stacktrace中不清楚,但可以在調試tomcat插件時找到它。

查看您的模塊的maven依賴關係mvn dependency:tree並查找servlet-api傳遞依賴關係。一旦發現從構建中排除它。