I am getting below exception when I am trying to run a Spring MVC application using Spring boot...
ContainerBase: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)
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:262)
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:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)Ljavax/servlet/ServletRegistration$Dynamic;
at org.springframework.boot.context.embedded.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:166)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:214)
at org.springframework.boot.context.embedded.tomcat.ServletContextInitializerLifecycleListener.lifecycleEvent(ServletContextInitializerLifecycleListener.java:54)
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:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
If you are using STS and you have added the Groovy library to your project (Project Properties -> Java Build Path -> Libraries), then make sure that you select the "No, only include groovy-all" option. The other option of "Yes, include groovy-all and bsf.jar ..., servlet-2.4.jar" adds servlet-2.4.jar which conflicts with the embedded tomcat8 classes resulting in this problem.
I also faced this error. I have a Maven/Spring MVC/Spring Boot project. I'm using IntelliJ as the IDE and whenever i add new dependancies to the POM.xml the IDE alters the .iml file (as expected) but what's weird is that it moves the following line to the top of the file:
once that happens my project will not compile and I get the same error:
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
by simply moving the orderEntry for Java EE back to the bottom the error goes away and I can compile once more.
I had this in a spring-boot webapp, only in the deployment server (was running fine on my local machine). I solve it by adding:
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html
According to this solution: https://stevewall123.wordpress.com/2015/04/17/spring-boot-application-and-tomcat-error-a-child-container-failed-during-start/
You can change the Tomcat version by setting the "tomcat.version" property:
it works for me, thanks to the author of that article.
Cheers :)
I am using Jetty in my project and got the same error. My quick solution was to exclude embedded Tomcat from the Maven dependency:
mvn dependency:tree
did not reveal theservlet-api.jar
on my classpath, but right-clicking the project (in Eclipse) and going to Build Path / Configure Build Path showed that my default workspace JRE, JDK 1.7.0_51, had that jar in itsjre/lib/ext
directory (at least in my installation). I tried and failed to remove it from my classpath. @Pedro's solution of forcing the tomcat version to 7 worked. So did installing the latest version of Java 7: JDK 1.7.0_79.