0

我用 jsf2 和 primefaces 3.2 开发了一个 webapp。在干净的 tomcat7 安装上,webapp 正在本地运行,没有任何问题。所以我将 .war 文件放到了我的 Linux 服务器上的 /var/lib/tomcat7/webapps 中。webapp 出现在 tomcat 管理器中,但没有运行。如果我尝试启动它,则会出现以下错误。

"FAIL - Application at context path /LnB-Sports could not be started"
"FAIL - Encountered exception org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([after_stop]) for component [org.apache.catalina.startup.FailedContext@130cd4a] in state [FAILED]"

这是catalina.out

Jun 10, 2013 9:45:58 AM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/LnB-Sports]
Jun 10, 2013 9:45:58 AM org.apache.catalina.util.LifecycleBase destroy
WARNING: Calling stop() on failed component [{0}] to trigger clean-up did not complete.
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([after_stop]) for component [org.apache.catalina.startup.FailedContext@b1666d] in state [FAILED]
    at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:408)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:249)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:272)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1043)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1272)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1450)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
    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.ContainerBase.backgroundProcess(ContainerBase.java:1379)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
    at java.lang.Thread.run(Thread.java:722)

Jun 10, 2013 9:45:58 AM org.apache.catalina.startup.HostConfig checkResources
WARNING: Error while removing context [/LnB-Sports]
java.lang.ClassCastException: org.apache.catalina.startup.FailedContext cannot be cast to org.apache.catalina.core.StandardContext
    at org.apache.catalina.startup.ContextConfig.destroy(ContextConfig.java:1074)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:365)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:312)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1043)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1272)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1450)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
    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.ContainerBase.backgroundProcess(ContainerBase.java:1379)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
    at java.lang.Thread.run(Thread.java:722)

Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:53:24 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:53:24 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:53:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:53:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:53:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2948 ms
Jun 10, 2013 9:53:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 10, 2013 9:53:28 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Jun 10, 2013 9:53:28 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml
Jun 10, 2013 9:53:30 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml
Jun 10, 2013 9:53:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Jun 10, 2013 9:53:31 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:53:31 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:53:31 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3164 ms
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:58:56 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:58:56 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:59:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:59:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:59:01 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2986 ms
Jun 10, 2013 9:59:01 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 10, 2013 9:59:01 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Jun 10, 2013 9:59:01 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml
Jun 10, 2013 9:59:06 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [3,329] milliseconds.
Jun 10, 2013 9:59:06 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml
Jun 10, 2013 9:59:06 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/LnB-Sports.war
Jun 10, 2013 9:59:06 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'context/Manager'.
Jun 10, 2013 9:59:06 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'context'.
Jun 10, 2013 9:59:07 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.startup.FailedContext@60659b]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.catalina.LifecycleException: Failed to process either the global, per-host or context-specific context.xml file therefore the [/LnB-Sports] Context cannot be started.
    at org.apache.catalina.startup.FailedContext.startInternal(FailedContext.java:153)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

Jun 10, 2013 9:59:07 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /var/lib/tomcat7/webapps/LnB-Sports.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.startup.FailedContext@60659b]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:898)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

Jun 10, 2013 9:59:07 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Jun 10, 2013 9:59:07 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 10, 2013 9:59:07 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2013 9:59:07 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6362 ms

感谢帮助 :)

4

1 回答 1

1
java.lang.ClassCastException: org.apache.catalina.startup.FailedContext cannot be cast to org.apache.catalina.core.StandardContext

这表明运行时类路径由于某种原因被多个不同版本的 Tomcat 内部库污染,例如catalina.jar. 这些多个不同版本的库相互冲突。

您需要绝对确保您的 webapp/WEB-INF/lib不包含任何特定于 servletcontainer 的 JAR 文件,例如catalina.jar,servlet-api.jar等。这将使您的 webapp 仅与 JAR 最初来自的特定 servletcontainer make/version 兼容,并且完全无法移植到另一个 servletcontainer 品牌/版本。您还需要绝对确保您没有触及 Tomcat 自己的/lib文件夹或 JRE/JDK自己的文件夹,/lib或者/lib/ext它们也参与运行时类路径(除非您真的知道自己在做什么,但不理解这一点ClassCastException表明这不是还是这样)。

于 2013-06-11T11:30:26.683 回答