问题描述
今天使用Maven做了个Struts2+Spring3+Hibernate4的小Demo,使用Tomcat7启动时报错,错误信息如下: 2013-12-2 13:53:49 org.apache.catalina.core.AprLifecycleListener init信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:jdk1.6bin;.;C:WINDOWSSunJavabin;C:WINDOWSsystem32;C:WINDOWS;D:/Java/jdk/bin/../jre/bin/client;D:/Java/jdk/bin/../jre/bin;D:/Java/jdk/bin/../jre/lib/i386;D:Javajdkbin;D:oracleapporacleproduct10.2.0serverbin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:Program FilesCommon FilesThunder NetworkKanKanCodecs;D:svnbin;D:rosecommon;D:mysqlbasebin;D:WPSWPSOffice9.1.0.4249office6;C:Program FilesStormIICodec;C:Program FilesStormII;D:Javajdkbin;D:maven3bin;D:antbin;D:btracebin;;D:epseclipse1.0.3;2013-12-2 13:53:50 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ssh_easyui_st' did not find a matching property.2013-12-2 13:53:52 org.apache.coyote.AbstractProtocol init信息: Initializing ProtocolHandler ["http-bio-8486"]2013-12-2 13:53:52 org.apache.coyote.AbstractProtocol init信息: Initializing ProtocolHandler ["ajp-bio-8219"]2013-12-2 13:53:52 org.apache.catalina.startup.Catalina load信息: Initialization processed in 3256 ms2013-12-2 13:53:52 org.apache.catalina.core.StandardService startInternal信息: Starting service Catalina2013-12-2 13:53:52 org.apache.catalina.core.StandardEngine startInternal信息: Starting Servlet Engine: Apache Tomcat/7.0.472013-12-2 13:53:53 org.apache.tomcat.websocket.server.WsSci onStartup信息: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocketJARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. 2013-12-2 13:53:53 org.apache.catalina.util.SessionIdGenerator createSecureRandom信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [234] milliseconds.2013-12-2 13:53:54 org.apache.catalina.core.ContainerBase startInternal严重: A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssh_easyui]]at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)at java.util.concurrent.FutureTask.get(FutureTask.java:83)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$Sync.innerRun(FutureTask.java:303)at java.util.concurrent.FutureTask.run(FutureTask.java:138)at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)at java.lang.Thread.run(Thread.java:619)Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssh_easyui]]at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)... 7 moreCaused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextat java.lang.Class.getDeclaredFields0(Native Method)at java.lang.Class.privateGetDeclaredFields(Class.java:2291)at java.lang.Class.getDeclaredFields(Class.java:1743)at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:263)at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:92)at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)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:5322)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)... 7 moreCaused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)... 21 more2013-12-2 13:53:54 org.apache.catalina.core.ContainerBase startInternal严重: A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)at java.util.concurrent.FutureTask.get(FutureTask.java:83)at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)at org.apache.catalina.startup.Catalina.start(Catalina.java:691)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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)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$Sync.innerRun(FutureTask.java:303)at java.util.concurrent.FutureTask.run(FutureTask.java:138)at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)at java.lang.Thread.run(Thread.java:619)Caused by: org.apache.catalina.LifecycleException: A child container failed during startat org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)... 7 more2013-12-2 13:53:54 org.apache.catalina.startup.Catalina start严重: The required Server component failed to start so Tomcat is unable to start.org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8325]]at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)at org.apache.catalina.startup.Catalina.start(Catalina.java:691)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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]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)... 7 moreCaused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]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)... 9 moreCaused by: org.apache.catalina.LifecycleException: A child container failed during startat 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)... 11 more2013-12-2 13:53:54 org.apache.coyote.AbstractProtocol pause信息: Pausing ProtocolHandler ["http-bio-8486"]2013-12-2 13:53:54 org.apache.coyote.AbstractProtocol pause信息: Pausing ProtocolHandler ["ajp-bio-8219"]2013-12-2 13:53:54 org.apache.catalina.core.StandardService stopInternal信息: Stopping service Catalina2013-12-2 13:53:54 org.apache.coyote.AbstractProtocol destroy信息: Destroying ProtocolHandler ["http-bio-8486"]2013-12-2 13:53:54 org.apache.coyote.AbstractProtocol destroy信息: Destroying ProtocolHandler ["ajp-bio-8219"] spring-context-3.1.2.RELEASE.jar这个包在maven中引入了,lib下可以看到,把target的classes文件删除重新编译或者换个tomcat[Tomcat_7039,Tomcat_7047]还是报错,很奇怪。使用jetty启动时成功,页面可以访问没问题,以前也遇到过tomcat启动报A child container failed during start错,但那是少包引起的,现在情况是包存在启动却报错,请教这是什么原因引起的?
解决方案
是不是jar包冲突,看下WEN-INF/lib报下是否存在不同版本spring-context
解决方案二:
应该是在不同的jar中,存在相同的包路径,但是在其中的一个路径中不存在指定的那个类。