title: Java. Spring boot. Application startup failed
body: <p>I'm trying to learn Spring Boot on my own. I use Maven and have created spring boot application with Tomcat container. When I use <em>mvn spring-boot:run</em> command to run the app it works fine. But when I start my app with ApplicationLoader class it gives me an error. Also, when I use ARC it gives me error <strong>404 not found</strong>.
  Of course, I understand that there's something wrong with my ApplicationLoader class, but I can't understand what exactly I should change to make it work. Your help is highly appreciated!</p>
  
  <p><strong>Application loader</strong></p>
  
  <pre><code>package com.boris2barak.samplemvc.app;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.builder.SpringApplicationBuilder;
  import org.springframework.boot.context.web.SpringBootServletInitializer;
  import org.springframework.context.annotation.ComponentScan;
  
  @SpringBootApplication
  
  public class ApplicationLoader extends SpringBootServletInitializer {
  
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder     application) {
  return application.sources(ApplicationLoader.class);
  }
  
  public static void main(String[] args) throws Exception {
  SpringApplication.run(ApplicationLoader.class, args);
  }
  }    
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>package com.boris2barak.samplemvc.app;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  
  @Controller
  public class myFirstController {
  
  
  @RequestMapping("/temperature")
  public String whatIsTheWeather(Model model, @RequestParam(value="city",        required=false, defaultValue="World") String city) {
  model.addAttribute("city", city);
  WeatherApp data = new WeatherApp();
  return    data.getTemperatureForCity(city);
  }
  }
  </code></pre>
  
  <p><strong>Pom file</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0     http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;groupId&gt;com.boris2barak&lt;/groupId&gt;
  &lt;artifactId&gt;samplemvc&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.3.5.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.6.2&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>And the mistake looks like that:</p>
  
  <pre><code>objc[1937]: Class JavaLaunchHelper is implemented in both       /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java      (0x1043444c0) and      /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstru      ment.dylib (0x1053b54e0). One of the two will be used. Which one is undefined.
  
    .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::        (v1.3.5.RELEASE)
  
  2017-07-23 10:13:07.163  INFO 1937 --- [           main]     c.b.samplemvc.app.ApplicationLoader      : Starting ApplicationLoader on MBP-Boris     with PID 1937 (/Users/boris/Java/samplemvc/target/classes started by boris in     /Users/boris/Java/samplemvc)
  2017-07-23 10:13:07.166  INFO 1937 --- [           main]     c.b.samplemvc.app.ApplicationLoader      : No active profile set, falling back to      default profiles: default
   2017-07-23 10:13:07.287  INFO 1937 --- [           main]      s.c.a.AnnotationConfigApplicationContext : Refreshing      org.springframework.context.annotation.AnnotationConfigApplicationContext@16022d9d     : startup date [Sun Jul 23 10:13:07 EEST 2017]; root of context hierarchy
  2017-07-23 10:13:07.450  WARN 1937 --- [           main]      s.c.a.AnnotationConfigApplicationContext : Exception encountered during context       initialization - cancelling refresh attempt:      org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse      configuration class [com.boris2barak.samplemvc.app.ApplicationLoader]; nested      exception is java.lang.IllegalStateException: Failed to introspect annotated      methods on class org.springframework.boot.context.web.SpringBootServletInitializer
  2017-07-23 10:13:07.487 ERROR 1937 --- [           main]      o.s.boot.SpringApplication               : Application startup failed
  
   org.springframework.beans.factory.BeanDefinitionStoreException: Failed to      parse configuration class [com.boris2barak.samplemvc.app.ApplicationLoader];      nested exception is java.lang.IllegalStateException: Failed to introspect      annotated methods on class      org.springframework.boot.context.web.SpringBootServletInitializer
      at      org.springframework.context.annotation.ConfigurationClassParser.parse(Configuratio     nClassParser.java:182) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassPostProcessor.processConf     igBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-     4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcess     BeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-     4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDe     finitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~     [spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at       org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFa      ctoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-      4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPo      stProcessors(AbstractApplicationContext.java:678) ~[spring-context-      4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApp     licationContext.java:520) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)       [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at      org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplicati     on.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at      org.springframework.boot.SpringApplication.run(SpringApplication.java:307)      [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at      org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)      [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at      org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)      [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at      com.boris2barak.samplemvc.app.ApplicationLoader.main(ApplicationLoader.java:24)       [classes/:na]
    Caused by: java.lang.IllegalStateException: Failed to introspect annotated      methods on class org.springframework.boot.context.web.SpringBootServletInitializer
      at      org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(Stand      ardAnnotationMetadata.java:163) ~[spring-core-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigura      tionClass(ConfigurationClassParser.java:292) ~[spring-context-      4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassParser.processConfigurati      onClass(ConfigurationClassParser.java:232) ~[spring-context-      4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassParser.parse(Configuratio     nClassParser.java:199) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at      org.springframework.context.annotation.ConfigurationClassParser.parse(Configuratio     nClassParser.java:168) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      ... 12 common frames omitted
   Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
      at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_131]
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~     [na:1.8.0_131]
      at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_131]
      at       org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(Stand      ardAnnotationMetadata.java:152) ~[spring-core-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      ... 16 common frames omitted
   Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~     [na:1.8.0_131]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
      ... 20 common frames omitted
  
  2017-07-23 10:13:07.502  INFO 1937 --- [           main]      .b.l.ClasspathLoggingApplicationListener : Application failed to start with      classpath:      [file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/charsets.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/deploy.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/     cldrdata.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/dnsns.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jaccess.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jfxrt.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/localedata.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/nashorn.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunec.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/zipfs.jar,      file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/javaws.jar,       file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jce.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfr.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfxswt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jsse.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/management-agent.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/plugin.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/resources.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/rt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/ant-javafx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/dt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/javafx-mx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/jconsole.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/packager.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/sa-jdi.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar, file:/Users/boris/Java/samplemvc/target/classes/, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.5.RELEASE/spring-boot-starter-web-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.5.RELEASE/spring-boot-starter-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot/1.3.5.RELEASE/spring-boot-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.5.RELEASE/spring-boot-autoconfigure-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.5.RELEASE/spring-boot-starter-logging-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/Users/boris/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/Users/boris/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/Users/boris/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/Users/boris/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/Users/boris/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/Users/boris/.m2/repository/org/springframework/spring-core/4.2.6.RELEASE/spring-core-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/Users/boris/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.5.RELEASE/spring-boot-starter-validation-1.3.5.RELEASE.jar, file:/Users/boris/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/Users/boris/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/Users/boris/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/Users/boris/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/Users/boris/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.6/jackson-databind-2.6.6.jar, file:/Users/boris/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.6/jackson-annotations-2.6.6.jar, file:/Users/boris/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.6/jackson-core-2.6.6.jar, file:/Users/boris/.m2/repository/org/springframework/spring-web/4.2.6.RELEASE/spring-web-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/spring-aop/4.2.6.RELEASE/spring-aop-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/Users/boris/.m2/repository/org/springframework/spring-beans/4.2.6.RELEASE/spring-beans-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/spring-context/4.2.6.RELEASE/spring-context-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/spring-webmvc/4.2.6.RELEASE/spring-webmvc-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/springframework/spring-expression/4.2.6.RELEASE/spring-expression-4.2.6.RELEASE.jar, file:/Users/boris/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.33/tomcat-embed-el-8.0.33.jar, file:/Users/boris/.m2/repository/com/google/code/gson/gson/2.6.2/gson-2.6.2.jar,      file:/Users/boris/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar,      file:/Applications/IntelliJ%20IDEA%20CE.app/Contents/lib/idea_rt.jar]
  
  Process finished with exit code 1
  </code></pre>