title: Spring Boot standalone jar crashing when config location is a Windows absolute path
body: <p>I built an application that depends on Spring Boot. As we are near to deploying it, I started testing the application outside of Eclipse and Gradle. This is where we ran into a crashing issue with in the early life-cycle of Spring Boot. The application runs fine within Eclipse and with <code>gradlew run</code>. However, it has problems with <code>java -jar &lt;App&gt;.jar</code>.</p>
  
  <p>The following is the exception that I am getting.</p>
  
  <pre><code>java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
          at java.lang.Thread.run(Thread.java:744)
  Caused by: java.lang.IllegalArgumentException: name
          at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:494)
          at sun.misc.URLClassPath.findResource(URLClassPath.java:176)
          at java.net.URLClassLoader$2.run(URLClassLoader.java:551)
          at java.net.URLClassLoader$2.run(URLClassLoader.java:549)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findResource(URLClassLoader.java:548)
          at org.springframework.boot.loader.LaunchedURLClassLoader.getResource(LaunchedURLClassLoader.java:63)
          at org.springframework.core.io.ClassPathResource.exists(ClassPathResource.java:138)
          at org.springframework.boot.env.PropertySourcesLoader.isFile(PropertySourcesLoader.java:88)
          at org.springframework.boot.env.PropertySourcesLoader.load(PropertySourcesLoader.java:74)
          at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:316)
          at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:295)
          at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:283)
          at org.springframework.boot.context.config.ConfigFileApplicationListener.addProperySources(ConfigFileApplicationListener.java:153)
          at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:135)
          at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:128)
          at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:117)
          at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
          at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:92)
          at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:58)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:275)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:880)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:869)
          at hello.SampleController.main(SampleController.java:18)
          ... 6 more
  </code></pre>
  
  <p>We are using Spring Boot 1.0.0.RC4. To isolate the problem, I copied the code from the tutorial (<a href="http://projects.spring.io/spring-boot/#quick-start" rel="nofollow">http://projects.spring.io/spring-boot/#quick-start</a>) and started a new Eclipse Gradle project. There is only one class file. It is pretty standard, except that I replaced <code>@Controller</code> with <code>@RestController</code> and removed <code>@ResponseBody</code>. Because that is what my application uses.</p>
  
  <p>Hello.java.</p>
  
  <pre><code>package hello;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  @EnableAutoConfiguration
  public class SampleController {
  
      @RequestMapping("/")
      String home() {
          return "Hello World!";
      }
  
      public static void main(String[] args) throws Exception {
          SpringApplication.run(SampleController.class, args);
      }
  }
  </code></pre>
  
  <p>I have a pretty standard <code>build.gradle</code> file.</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'eclipse'
  
  buildscript {
      repositories {
          maven { url 'http://repo.spring.io/libs-snapshot' }
          mavenLocal()
      }
      dependencies { classpath('org.springframework.boot:spring-boot-gradle-plugin:1.0.0.RC4') }
  }
  
  apply plugin: 'spring-boot'
  
  repositories {
      mavenCentral()
      maven { url 'http://repo.spring.io/milestone' }
      maven { url "http://repo.spring.io/libs-snapshot" }
  }
  
  dependencies { compile 'org.springframework.boot:spring-boot-starter-web:1.0.0.RC4' }
  
  task wrapper(type: Wrapper) { gradleVersion = '1.11' }
  </code></pre>
  
  <p>With this test hello application, I did <code>gradlew clean build</code> and then tried <code>java -jar Hello.jar</code>. Imagine my surprise when I received the same exception as above. Maybe I'm still missing something, but this outcome seems to indicate that there is perhaps a problem with Spring Boot?</p>
  
  <p>I would greatly appreciate a solution ... any solution (even if it is a dirty workaround).</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>As requested, the machine I'm testing the standalone jar is on Windows (8.1).</p>
  
  <pre><code>java version "1.7.0_51"
  Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
  Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>As requested, I also tested the <code>spring-boot-sample-web-ui</code>. The same exception still occurs.</p>
  
  <p><strong>EDIT 3:</strong> Salutations to @DaveSyer</p>
  
  <p>I may have discovered a potential cause. The environment variable <code>SPRING_CONFIG_LOCATION</code> seems to be causing the exception. When it is not set, the test <code>Hello</code> application and the <code>spring-boot-sample-web-ui</code> application worked as intended.</p>
  
  <p><strong>EDIT 4:</strong></p>
  
  <p>For anyone else interested, I've uploaded the test application to GitHub (<a href="https://github.com/ChrisZhong/spring-boot-jar-sample" rel="nofollow">https://github.com/ChrisZhong/spring-boot-jar-sample</a>)</p>