title: Spring Boot + Gradle + War + Standalone Tomcat: Application is not loading
body: <p>I went into frustration after attempting many times to solve the below simple puzzle.</p>
  
  <p>I created a web application(war) from spring.io. Very simple demo and you can take a look at this git repository: <a href="https://github.com/haigopi/SpringBootGradleStandaloneTomcatWarTest" rel="nofollow noreferrer">https://github.com/haigopi/SpringBootGradleStandaloneTomcatWarTest</a></p>
  
  <pre><code>Had only two classes (DemoApplication.java and ServletInitializer.java) 
  and a Single application.properties.
  </code></pre>
  
  <p>Running gradle build will produce a demo.war(Also committed to repository) which I copied to tomcat(7/CentOs) webapps and then started the server.</p>
  
  <p>Following is the tree structure of my tomcat logs:</p>
  
  <pre><code>[root@localhost logs]# tree
  .
  ├── catalina.2016-12-25.log
  ├── host-manager.2016-12-25.log
  ├── localhost.2016-12-25.log
  ├── localhost_access_log.2016-12-25.txt
  └── manager.2016-12-25.log
  </code></pre>
  
  <p>localhost.2016-12-25.log file got the below log after I stared the server:</p>
  
  <pre><code>Dec 25, 2016 5:26:31 PM org.apache.catalina.core.ApplicationContext log
  INFO: 2 Spring WebApplicationInitializers detected on classpath
  Dec 25, 2016 5:26:33 PM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring embedded WebApplicationContext
  </code></pre>
  
  <p>and so catalina.2016-12-25.log:</p>
  
  <pre><code>INFO: Starting Servlet Engine: Apache Tomcat/7.0.69
  Dec 25, 2016 5:26:30 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive /var/lib/tomcat/webapps/demo-0.0.1-SNAPSHOT.war
  Dec 25, 2016 5:26:31 PM org.apache.catalina.startup.TldConfig execute
  INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  Dec 25, 2016 5:26:35 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deployment of web application archive /var/lib/tomcat/webapps/demo-0.0.1-SNAPSHOT.war has finished in 5,599 ms
  Dec 25, 2016 5:26:35 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Dec 25, 2016 5:26:35 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Dec 25, 2016 5:26:35 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 5650 ms
  </code></pre>
  
  <p>I don't see the spring boot application started as no sysouts printed (from DemoApplication.java and ServletInitializer) anywhere nor the spring boot banner and also I tried adding a controller which is not reachable either.</p>
  
  <p>Can some one shed some light? </p>
  
  <p>for quick view I am printing the structure of war file:</p>
  
  <pre><code>[root@localhost demo-0.0.1-SNAPSHOT]# tree
  .
  ├── META-INF
  │   └── MANIFEST.MF
  ├── org
  │   └── springframework
  │       └── boot
  │           └── loader
  │               ├── archive
  │               │   ├── Archive.class
  │               │   ├── Archive$Entry.class
  │               │   ├── Archive$EntryFilter.class
  │               │   ├── ExplodedArchive$1.class
  │               │   ├── ExplodedArchive.class
  │               │   ├── ExplodedArchive$FileEntry.class
  │               │   ├── ExplodedArchive$FileEntryIterator.class
  │               │   ├── ExplodedArchive$FileEntryIterator$EntryComparator.class
  │               │   ├── JarFileArchive.class
  │               │   ├── JarFileArchive$EntryIterator.class
  │               │   └── JarFileArchive$JarFileEntry.class
  │               ├── data
  │               │   ├── ByteArrayRandomAccessData.class
  │               │   ├── RandomAccessData.class
  │               │   ├── RandomAccessDataFile.class
  │               │   ├── RandomAccessDataFile$DataInputStream.class
  │               │   ├── RandomAccessDataFile$FilePool.class
  │               │   └── RandomAccessData$ResourceAccess.class
  │               ├── ExecutableArchiveLauncher$1.class
  │               ├── ExecutableArchiveLauncher.class
  │               ├── jar
  │               │   ├── AsciiBytes.class
  │               │   ├── Bytes.class
  │               │   ├── CentralDirectoryEndRecord.class
  │               │   ├── CentralDirectoryFileHeader.class
  │               │   ├── CentralDirectoryParser.class
  │               │   ├── CentralDirectoryVisitor.class
  │               │   ├── FileHeader.class
  │               │   ├── Handler.class
  │               │   ├── JarEntry.class
  │               │   ├── JarEntryFilter.class
  │               │   ├── JarFile$1.class
  │               │   ├── JarFile$2.class
  │               │   ├── JarFile$3.class
  │               │   ├── JarFile.class
  │               │   ├── JarFileEntries$1.class
  │               │   ├── JarFileEntries.class
  │               │   ├── JarFileEntries$EntryIterator.class
  │               │   ├── JarFile$JarFileType.class
  │               │   ├── JarURLConnection$1.class
  │               │   ├── JarURLConnection.class
  │               │   ├── JarURLConnection$JarEntryName.class
  │               │   └── ZipInflaterInputStream.class
  │               ├── JarLauncher.class
  │               ├── LaunchedURLClassLoader$1.class
  │               ├── LaunchedURLClassLoader.class
  │               ├── Launcher.class
  │               ├── MainMethodRunner.class
  │               ├── PropertiesLauncher$1.class
  │               ├── PropertiesLauncher$ArchiveEntryFilter.class
  │               ├── PropertiesLauncher.class
  │               ├── PropertiesLauncher$FilteredArchive$1.class
  │               ├── PropertiesLauncher$FilteredArchive.class
  │               ├── PropertiesLauncher$PrefixMatchingArchiveFilter.class
  │               ├── util
  │               │   └── SystemPropertyUtils.class
  │               └── WarLauncher.class
  └── WEB-INF
      ├── classes
      │   ├── application.properties
      │   ├── com
      │   │   └── example
      │   │       ├── DemoApplication.class
      │   │       └── ServletInitializer.class
      │   ├── static
      │   └── templates
      ├── lib
      │   ├── classmate-1.3.3.jar
      │   ├── hibernate-validator-5.2.4.Final.jar
      │   ├── jackson-annotations-2.8.5.jar
      │   ├── jackson-core-2.8.5.jar
      │   ├── jackson-databind-2.8.5.jar
      │   ├── jboss-logging-3.3.0.Final.jar
      │   ├── jcl-over-slf4j-1.7.22.jar
      │   ├── jul-to-slf4j-1.7.22.jar
      │   ├── log4j-over-slf4j-1.7.22.jar
      │   ├── logback-classic-1.1.8.jar
      │   ├── logback-core-1.1.8.jar
      │   ├── slf4j-api-1.7.22.jar
      │   ├── snakeyaml-1.17.jar
      │   ├── spring-aop-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-beans-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-boot-2.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-boot-autoconfigure-2.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-boot-starter-2.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-boot-starter-logging-2.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-boot-starter-web-2.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-context-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-core-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-expression-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-web-5.0.0.BUILD-SNAPSHOT.jar
      │   ├── spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar
      │   └── validation-api-1.1.0.Final.jar
      └── lib-provided
          ├── spring-boot-starter-tomcat-2.0.0.BUILD-SNAPSHOT.jar
          ├── tomcat-embed-core-8.5.6.jar
          ├── tomcat-embed-el-8.5.6.jar
          └── tomcat-embed-websocket-8.5.6.jar
  </code></pre>
  
  <p>and manifest file:</p>
  
  <pre><code>[root@localhost META-INF]# cat MANIFEST.MF 
  Manifest-Version: 1.0
  Start-Class: com.example.DemoApplication
  Spring-Boot-Classes: WEB-INF/classes/
  Spring-Boot-Lib: WEB-INF/lib/
  Spring-Boot-Version: 2.0.0.BUILD-SNAPSHOT
  Main-Class: org.springframework.boot.loader.WarLauncher
  </code></pre>