title: Using ResourceUtils.getFile to read a file from classpath in Heroku environment
body: <p>I'm running a Spring Boot application in Heroku, using Maven to manage the build lifecycle.</p>
  
  <p>During the initialisation phase of my application, I want to read a file packaged into my JAR file.</p>
  
  <p>To manage to get the content of the file I'm using the Spring utility class <code>ResourceUtils</code>, and I'm expressing the path of the file using the special prefix <code>classpath:</code>.</p>
  
  <p>The code I'm using looks like this:</p>
  
  <pre><code>String pathToMyFile = "classpath:com/myapp/myFile.test"
  List&lt;String&gt; fileLines = Files.readLines(ResourceUtils.getFile(pathToMyFile), IOConstants.DEFAULT_CHARSET_TYPE);
  </code></pre>
  
  <p>This code works as expected when I execute the application in my local machine.</p>
  
  <p>But when I push my application to Heroku I'm getting the following error:</p>
  
  <pre><code>Caused by: java.io.FileNotFoundException: class path resource [com/myapp/myFile.test] 
  cannot be resolved to absolute file path because it does not reside in the 
  file system: jar:file:/app/target/myapp.jar!/com/myapp/myFile.test 
  </code></pre>
  
  <p>I've run a <code>heroku run bash</code> and I've checked that the file is just where it should be (inside the jar).</p>
  
  <p>Moreover, according to the error trace, Spring locates the file, because it transform the path from <code>classpath:com/myapp/myFile.test</code> to <code>jar:file:/app/target/myapp.jar!/com/myapp/myFile.test</code></p>