Banging My Head Against the Wall

What I wish I knew before I started…

Spring Boot Application and Tomcat error: A child container failed during start


I was attempting to create my first Spring Boot web application this afternoon by following the Spring Boot Getting Started Tutorial on spring.io, yet attempting to do the steps in Eclipse Luna with Java 8 and an embedded Tomcat 7 server.

Upon trying to start the Tomcat 7 server from within Eclipse, I received the following error – Notice hidden in the error stack: Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName():

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MavenWebDemo]]
 at java.util.concurrent.FutureTask.report(FutureTask.java:122)
 at java.util.concurrent.FutureTask.get(FutureTask.java:192)
 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:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MavenWebDemo]]
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
 ... 6 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
 at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147)
 at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
 at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 ... 6 more

After some searching, I found the solution buried in the Spring Boot documentation for how to embed Servlet containers.  It was as simple as adding a “tomcat.version” property to your Maven project’s pom.xml file:

<properties>
    <tomcat.version>7.0.52</tomcat.version>
</properties>
<dependencies>
    ...

 

Spring Boot defaults to Tomcat 8, so I needed the tomcat.version property to tell Spring Boot that I intend to target Tomcat 7.

I restarted my server and it started right up!

 

, , , ,

7 responses to “Spring Boot Application and Tomcat error: A child container failed during start”

  1. Hi thanks for posting!
    As a note for others, I also saw the same exception when attempting to deploy a war to tomcat (instead of using an embedded container). The solution was to add this to the pom

    org.springframework.boot
    spring-boot-starter-tomcat
    provided
    ${spring.boot.version}

Leave a comment