title: SpringBoot WAR file deployed into Tomcat running but still returning 404
body: <p>I want to demonstrate a simple SpringBoot application being deployed into a separately running Tomcat instance. Even though my application appears to have been deployed, I cannot access it in Tomcat.</p>
  
  <p>I have followed the 'Traditional deployment' instructions in the Spring <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html" rel="nofollow noreferrer">documentation</a>.</p>
  
  <p>I have tried using a different version of Tomcat and running the war file as <code>ROOT.war</code>but get similar behaviour.</p>
  
  <p>When I run the war standalone e.g. <code>java -jar build/libs/springbootify.war</code> I can successfully access the expected URL <code>http://localhost:8080/doit</code>.</p>
  
  <p><strong>Application.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@SpringBootApplication
  public class Application extends SpringBootServletInitializer {
      public static void main(String[] args) {
          SpringApplication.run(Application.class);
      }
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
          return builder.sources(Application.class);
      }
  }
  </code></pre>
  
  <p><strong>MyController.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@RestController
  public class MyController {
      @GetMapping(value = "/doit")
      public String getSomething() {
          return "Something";
      }
  }
  
  </code></pre>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>plugins {
      id 'war'
      id 'java'
      id 'io.spring.dependency-management' version "1.0.8.RELEASE"
      id 'org.springframework.boot' version '2.1.6.RELEASE'
      id 'com.palantir.docker' version '0.22.1'
      id 'com.palantir.docker-run' version '0.22.1'
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile 'org.springframework.boot:spring-boot-starter-web'
      providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
      compile 'org.springframework.boot:spring-boot-devtools'
  }
  </code></pre>
  
  <p>See the reproducible example on <a href="https://github.com/tkgregory/springbootify/tree/stackoverflow" rel="nofollow noreferrer">Github</a>.</p>
  
  <p>I can see that the war file has been deployed in the Tomcat logs </p>
  
  <pre><code>29-Jun-2019 17:07:04.434 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/springbootify.war] has finished in [857] ms
  </code></pre>
  
  <p>However, when I access <code>http://localhost:8080/springbootify/doit</code> I get a 404 response.</p>
  
  <p>I expect this to return the string "something" with a 200 response.</p>
  
  <p><strong>UPDATE - 2019-07-12</strong></p>
  
  <p>I have tried building the war using Maven, and manually deploying to Tomcat via the manager UI and this works correctly</p>
  
  <p>Inspecting the difference between the war files generated by Gradle and Maven I found the following:</p>
  
  <p>1) Maven adds these additional attributes to the <code>META-INF/MANIFEST.MF</code>:</p>
  
  <pre><code>Created-By: Maven Archiver 3.4.0
  Build-Jdk-Spec: 12
  Implementation-Title: springbootify
  Implementation-Version: 0.0.1-SNAPSHOT
  </code></pre>
  
  <p>2) Maven adds this additional library to the war:</p>
  
  <p><code>WEB-INF/lib/javax.annotation-api-1.3.2.jar</code> whereas in the Gradle war it is in <code>WEB-INF/lib-provided/javax.annotation-api-1.3.2.jar</code></p>
  
  <p>I'm going to suppose it's one of these reasons that it's not working with Gradle, but so far I haven't managed to modify the Gradle generated war to include these differences.</p>
  
  <p>The newly added <code>pom.xml</code> can also be viewed on the provided <a href="https://github.com/tkgregory/springbootify" rel="nofollow noreferrer">Github link</a>.</p>