Stack Exchange
Spring Boot Tomcat Container Deployment Errors
I would like to deploy my Spring Boot application as a WAR to a Tomcat Container, but Tomcat is unable to start the container.  I have followed the documentation, Traditional Deployment Section from the Spring Boot Reference.  The container's thread size is set to -Xss 4068, but I'm still getting a stack overflow error.
Here is the stack trace:
Dec 08, 2014 12:01:13 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Tomcat\customer\webapps\customer-site-0.0.1-SNAPSHOT\WEB-
INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. 
Offending class: javax/servlet/Servlet.class
Dec 08, 2014 12:01:15 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[customers-prototype.mydomain.com].StandardContext[/customer-site-0.0.1-SNAPSHOT]]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
  at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
  at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
  at java.util.concurrent.FutureTask.run(FutureTask.java:166)
  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:722)
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/customer-site-0.0.1-SNAPSHOT] due to a StackOverflowError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [com.ibm.db2.jcc.am.mf->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object->java.lang.Object]
  at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2126)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2072)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1947)
  at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1913)
  at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1898)
  at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1330)
  at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
  at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
  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:5380)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more

Dec 08, 2014 12:01:15 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive C:\Tomcat\customer\webapps\customer-site-0.0.1-SNAPSHOT.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[customers-prototype.mydomain.com].StandardContext[/customer-site-0.0.1-SNAPSHOT]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
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:722)

Dec 08, 2014 12:01:15 AM org.apache.catalina.startup.HostConfig deployWAR

My pom.xml has the following Spring Boot dependency with the spring-boot-starter-tomcat scope set to provided as described in the documentation.
POM.XML
    <!-- Spring Boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- Spring Security -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.security.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

UPDATED: Additional pom dependencies:
<dependency>
   <groupId>com.ibm.db2</groupId>
   <artifactId>db2jcc4</artifactId>
   <version>9.7.0.9</version>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
   <artifactId>db2jcc_license</artifactId>
   <version>9.7.0.9</version>
</dependency>

My main class extends the SpringBootServletInitializer as described in the documents:
CustomerSiteMain.java:
@Configuration
@ComponentScan("com.mydomain")
@EnableAutoConfiguration
public class CustomerMain extends SpringBootServletInitializer{

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
        return application
            .showBanner(true)
            .parent(Global.class)
            .sources(CustomerMain.class)
            .profiles("container");
    }

    public static void main(String[] args) {
        SpringApplication.run(CustomerMain.class, args);
    }

   @Bean
   @Profile(CustomerSiteProfiles.STANDALONE)
   public ServletRegistrationBean h2Console() {
      ServletRegistrationBean reg = new ServletRegistrationBean(new WebServlet(), "/console/*");
      reg.setLoadOnStartup(1);
      return reg;
   }

   @Bean
   public ServletRegistrationBean servletRegistrationBean(){
       return new ServletRegistrationBean(new PhotoSheetPDFServlet(), "/items/factsheet/*");
   }
}


where does "com.ibm.db2.jcc.am.mf" come from? Could you show the part of your pom that adds that dependency as well?

@BrianClozel That is the DB2 JDBC driver.  I added the additional dependency information to pom section of the code.

The above helped me out as well.  I had a similar issue and kept getting WebappClassLoader logs like this: 
2015-03-06 20:32:53,741 org.apache.catalina.loader.WebappClassLoader   validateJarFile INFO: validateJarFile(/usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0/WEB-INF/lib/tomcat-embed-core-8.0.15.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
2015-03-06 20:32:53,742 org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0/WEB-INF/lib/tomcat-embed-el-8.0.15.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class

which were a clue to this SEVERE error I got with the web application loading.
2015-03-06 20:32:54,704 org.apache.catalina.startup.HostConfig deployWAR SEVERE: Error deploying web application archive /usr/local/apache-tomcat-7.0.54/webapps/gs-producing-web-service-0.1.0.war

I was developing a web service in my case and these depencies (web service not web) in my pom.xml
<dependencies>
    <!-- tag::springws[] -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-ws</artifactId>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
    </dependency>
    <!-- end::springws[] -->
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency> 
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency> 
</dependencies>

But I was forgetting to do a clean as well before a maven install.  This cost my a few hours because my tomcat libraries were still there.
USER BEWARE that you should also do a maven clean when you follow Springs https://spring.io/guides/gs/convert-jar-to-war/ and http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file 
This is great now for more rapid development.  Thanks

It seems like your Tomcat is trying to load some classes that have already been loaded. 
Try to exclude an embeded tomcat from spring-boot-starter-web dependency
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

