title: Spring Boot war file works with embedded but not with standalone Tomcat
body: <p>I want to create a war file from a <strong>Spring Boot application, which I can deploy to a standalone Tomcat container, not using the embedded one.</strong> </p>
  
  <p>I can create the war file and run it on its own using <code>"java -jar pdfjs-annotator.war"</code> and it works fine. </p>
  
  <p>I built the application using <code>gradle bootRepackage</code> (Using Gradle, Tomcat7, Java 1.7).</p>
  
  <p>But when I deploy the war file to a standalone Tomcat and start it, the app seems to boot without errors according to the log, but I cannot access any of the resources nor do the controller urls work.</p>
  
  <p>For example, my index.html is a static html page under src/main/resources/static/index.html, which I can usually call via localhost:8080/index.html, but when deployed to a standalone Tomcat, the page does not get delivered (it's then in the war file in WEB-INF/classes/static/index.html) through that same url. And also any kind of controller mapping don't seem to work. I am getting a 404 error instead.</p>
  
  <p><strong>build.gradle:</strong></p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.2.3.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
          classpath("io.spring.gradle:dependency-management-plugin:0.5.0.RELEASE")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse-wtp'
  apply plugin: 'idea'
  apply plugin: 'spring-boot' 
  apply plugin: 'io.spring.dependency-management' 
  apply plugin: 'war'
  
  
  war {
      baseName = 'pdfjs-annotator'
      version = '1.0.0-SNAPSHOT'
  }
  
  allprojects {
      apply plugin: 'java'
      sourceCompatibility = 1.6
      targetCompatibility = 1.6
  }
  
  repositories {
      mavenCentral()
  }
  
  configurations {
      providedRuntime
  }
  
  dependencies {
      compile("org.springframework.boot:spring-boot-starter-data-jpa")
      compile("org.springframework.boot:spring-boot-starter-data-rest")
      compile("org.springframework.boot:spring-boot-starter-web")
      runtime("mysql:mysql-connector-java")
      providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
      testCompile("org.springframework.boot:spring-boot-starter-test")
      compile ('org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final')
  }
  
  
  eclipse {
      classpath {
           containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
           containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
      }
  }
  
  task wrapper(type: Wrapper) {
      gradleVersion = '2.3'
  }
  </code></pre>
  
  <p>My main <strong>application</strong> class:</p>
  
  <pre><code>@EnableJpaRepositories
  @SpringBootApplication
  public class PdfAnnotator extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication.run(PdfAnnotator.class, args);
      }
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(PdfAnnotator.class);
      }
  
  }
  </code></pre>
  
  <p>When I look into the exploded war, I do see the following <strong>META-INF/MANIFEST.MF</strong>:</p>
  
  <pre><code>Manifest-Version: 1.0
  Start-Class: com.mypackage.pdfcomment.PdfAnnotator
  Spring-Boot-Version: 1.2.3.RELEASE
  Main-Class: org.springframework.boot.loader.WarLauncher
  </code></pre>
  
  <p>The gradle build process usually generated two war artifacts, one named .war and one named .war.original - the .war is the one that holds proper MANIFEST.MF entries and it's the one I used to deploy to the standalone Tomcat.</p>
  
  <p>What's missing? I already checked other questions here on SO: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/25991789/spring-boot-war-without-tomcat-embedded">spring boot war without tomcat embedded</a></li>
  <li><a href="https://stackoverflow.com/questions/29255221/deploying-a-war-in-tomcat">Deploying a WAR in tomcat</a></li>
  </ul>
  
  <p>and also the Spring Boot docs, but could not find a hint of what's wrong. </p>
  
  <p><strong>* === Update === *</strong></p>
  
  <p>I installed a brand new Tomcat7, deployed the war file there, and everything's working fine. Seemed to be some issue with the Tomcat instance/configuration I had running. Not sure what exactly the issue was, but I won't bother to check it further since it's working fine now with the new Tomcat.</p>