title: Spring Application won't start: Application failed to start with classpath
body: <p>Very strange problem that has me dead in the water.</p>
  
  <p>My Spring application was running perfectly, then I added a Singleton class that read an argv from the main method to determine whether to start in production or dev mode.</p>
  
  <p>Then I get the error <code>Application failed to start with classpath</code> as soon as a standard class library was used, in this case <code>InputStream</code>.</p>
  
  <p>So I reverted all the code I changed back to how it was on the last successful run, and the problem persists:</p>
  
  <pre><code>.b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/deploy.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/ext/zipfs.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/javaws.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/jfxswt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/management-agent.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/plugin.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_112/jre/lib/rt.jar, file:/C:/Dev/EnatureRestService/target/classes/, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.9.RELEASE/spring-boot-starter-web-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.9.RELEASE/spring-boot-starter-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot/1.5.9.RELEASE/spring-boot-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.9.RELEASE/spring-boot-autoconfigure-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.9.RELEASE/spring-boot-starter-logging-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar, file:/C:/Users/Ashoka/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar, file:/C:/Users/Ashoka/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar, file:/C:/Users/Ashoka/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.25/log4j-over-slf4j-1.7.25.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.9.RELEASE/spring-boot-starter-tomcat-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.23/tomcat-embed-core-8.5.23.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/tomcat/tomcat-annotations-api/8.5.23/tomcat-annotations-api-8.5.23.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.23/tomcat-embed-el-8.5.23.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.23/tomcat-embed-websocket-8.5.23.jar, file:/C:/Users/Ashoka/.m2/repository/org/hibernate/hibernate-validator/5.3.6.Final/hibernate-validator-5.3.6.Final.jar, file:/C:/Users/Ashoka/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/Ashoka/.m2/repository/org/jboss/logging/jboss-logging/3.3.1.Final/jboss-logging-3.3.1.Final.jar, file:/C:/Users/Ashoka/.m2/repository/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar, file:/C:/Users/Ashoka/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.10/jackson-databind-2.8.10.jar, file:/C:/Users/Ashoka/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar, file:/C:/Users/Ashoka/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.10/jackson-core-2.8.10.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-web/4.3.13.RELEASE/spring-web-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-beans/4.3.13.RELEASE/spring-beans-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-context/4.3.13.RELEASE/spring-context-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-webmvc/4.3.13.RELEASE/spring-webmvc-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-expression/4.3.13.RELEASE/spring-expression-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter-security/1.5.9.RELEASE/spring-boot-starter-security-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-aop/4.3.13.RELEASE/spring-aop-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/security/spring-security-config/4.2.3.RELEASE/spring-security-config-4.2.3.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/security/spring-security-core/4.2.3.RELEASE/spring-security-core-4.2.3.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/security/spring-security-web/4.2.3.RELEASE/spring-security-web-4.2.3.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/session/spring-session/1.3.1.RELEASE/spring-session-1.3.1.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/boot/spring-boot-starter-data-mongodb/1.5.9.RELEASE/spring-boot-starter-data-mongodb-1.5.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/data/spring-data-mongodb/1.10.9.RELEASE/spring-data-mongodb-1.10.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/spring-tx/4.3.13.RELEASE/spring-tx-4.3.13.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/springframework/data/spring-data-commons/1.13.9.RELEASE/spring-data-commons-1.13.9.RELEASE.jar, file:/C:/Users/Ashoka/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/logging/log4j/log4j-jcl/2.10.0/log4j-jcl-2.10.0.jar, file:/C:/Users/Ashoka/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/logging/log4j/log4j-api/2.7/log4j-api-2.7.jar, file:/C:/Users/Ashoka/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar, file:/C:/Users/Ashoka/.m2/repository/org/mongodb/mongodb-driver/3.5.0/mongodb-driver-3.5.0.jar, file:/C:/Users/Ashoka/.m2/repository/org/mongodb/bson/3.5.0/bson-3.5.0.jar, file:/C:/Users/Ashoka/.m2/repository/org/mongodb/mongodb-driver-core/3.5.0/mongodb-driver-core-3.5.0.jar, file:/C:/Users/Ashoka/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar, file:/C:/Users/Ashoka/.m2/repository/commons-codec/commons-codec/1.8/commons-codec-1.8.jar, file:/C:/Users/Ashoka/.m2/repository/commons-validator/commons-validator/1.6/commons-validator-1.6.jar, file:/C:/Users/Ashoka/.m2/repository/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar, file:/C:/Users/Ashoka/.m2/repository/commons-digester/commons-digester/2.1/commons-digester-2.1.jar, file:/C:/Users/Ashoka/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar, file:/C:/Users/Ashoka/.m2/repository/org/apache/httpcomponents/httpcore/4.4.8/httpcore-4.4.8.jar, file:/C:/Users/Ashoka/.m2/repository/com/google/code/gson/gson/2.8.1/gson-2.8.1.jar, file:/C:/Users/Ashoka/.m2/repository/org/json/json/20170516/json-20170516.jar, file:/C:/Users/Ashoka/.m2/repository/org/mongodb/morphia/morphia/1.3.2/morphia-1.3.2.jar, file:/C:/Users/Ashoka/.m2/repository/org/mongodb/mongo-java-driver/3.4.3/mongo-java-driver-3.4.3.jar, file:/C:/Users/Ashoka/.m2/repository/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar, file:/C:/Users/Ashoka/.m2/repository/com/thoughtworks/proxytoys/proxytoys/1.0/proxytoys-1.0.jar, file:/C:/Users/Ashoka/.m2/repository/org/yaml/snakeyaml/1.18/snakeyaml-1.18.jar, file:/C:/Users/Ashoka/.m2/repository/org/sql2o/sql2o/1.5.4/sql2o-1.5.4.jar, file:/C:/Users/Ashoka/.m2/repository/org/mp4parser/isoparser/1.9.27/isoparser-1.9.27.jar, file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202017.1.1/lib/idea_rt.jar]
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Invocation of init method failed; nested exception is java.lang.NullPointerException
      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
      at io.nolawnchairs.etv.Application.main(Application.java:35) [classes/:na]
  Caused by: java.lang.NullPointerException: null
  </code></pre>
  
  <p>The NullPointer refers to:</p>
  
  <pre><code>// filename refers to a string pointing to a valid resource file
  InputStream is = this.getClass().getResourceAsStream(filename); // is: null
  InputStreamReader isr = new InputStreamReader(is);
  </code></pre>
  
  <p>From what I can gather, something may have gone wrong with a maven call, but I have no idea what the problem is, or how to fix it.</p>
  
  <p>Fixed:
  Closed my IDE (JetBrains), ran <code>mvn clean</code> and restarted the IDE. Works. Not sure why, but it works.</p>