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!

 

Advertisements

About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Drools, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in Java 8, Maven, Spring, Spring Boot, Tomcat and tagged , , , , . Bookmark the permalink.

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

  1. Kapil says:

    Excellent. Solved my problem after lot of trails. Thanks.

  2. Amritpal SIngh says:

    Thanks.Solved my problem.

  3. Jmp Jmp says:

    Excellent. Your post saved my time. Thanks.

  4. Dean Pullen says:

    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}

  5. Daniel says:

    Ah yes this did the trick! Thanks.

  6. Thanks a ton, this saved me a lot of time!

  7. Dheeraj says:

    Thanks. This worked for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s