严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component
自己写了个最简单的springMVC项目练练手,没有用maven,在WebContent中新建了lib文件夹,将jar包复制到这里面,然后add to build path到项目里。
启动Tomcat,报错,启动不起来。在网页中运行localhost:8080发现Tomcat页面是可以打开的。
报错内容如下:
1 严重: A child container failed during start 2 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhang]] 3 at java.util.concurrent.FutureTask.report(FutureTask.java:122) 4 at java.util.concurrent.FutureTask.get(FutureTask.java:188) 5 at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) 6 at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799) 7 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 8 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 9 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 10 at java.util.concurrent.FutureTask.run(FutureTask.java:262) 11 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 12 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 13 at java.lang.Thread.run(Thread.java:745) 14 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhang]] 15 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 16 ... 6 more 17 Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext 18 at java.lang.Class.getDeclaredFields0(Native Method) 19 at java.lang.Class.privateGetDeclaredFields(Class.java:2436) 20 at java.lang.Class.getDeclaredFields(Class.java:1806) 21 at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106) 22 at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261) 23 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140) 24 at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65) 25 at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:403) 26 at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:879) 27 at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374) 28 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) 29 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 30 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355) 31 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 32 ... 6 more 33 Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.WebApplicationContext 34 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) 35 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) 36 ... 20 more
网上百度大家都说是jar包缺少。但是检查spring所需要的jar包,都存在,如下图。
然后就看lib文件是不是有问题,果然有问题。
原来我的lib文件夹在WebContent下,将它放到WEB-INF目录下,再重新将jar包add to build path里,项目就能启动了。
现在将这个问题分享出来,希望能帮到其他的朋友。
可能我犯得这个错误很低级,别人不会犯这种错误吧。^_^