title: Issue with Tomcat starting - Bean Creation Exception
body: <p>i tried start my spring boot application in debian following:</p>
  
  <pre><code>java -jar my-app-backend-0.0.1-SNAPHOST.jar 
  </code></pre>
  
  <p>and i have error:</p>
  
  <blockquote>
    <p>o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat
    context. Exception:
    org.springframework.beans.factory.BeanCreationException. Message:
    Error creating bean with name 'securityConfig': Invocation of init
    method failed; nested exception is java.io.FileNotFoundException:
    class path resource [secret.key] cannot be resolved to absolute file
    path because it does not reside in the file system:
    jar:file:/home/my-app-backend-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/secret.key</p>
  </blockquote>
  
  <p>What is the problem?</p>
  
  <pre><code>pom.xml
  
  &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;groupId&gt;com.findme&lt;/groupId&gt;
      &lt;artifactId&gt;my-app-backend&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;my-app-backend&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&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;2.0.0.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&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-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&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.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.auth0&lt;/groupId&gt;
              &lt;artifactId&gt;java-jwt&lt;/artifactId&gt;
              &lt;version&gt;3.2.0&lt;/version&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>SecurityConfig.java</p>
  
  <pre><code>package com.findme.myappbackend.security;
  
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.context.annotation.Bean;
  import org.springframework.core.io.Resource;
  import org.springframework.http.HttpMethod;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
  
  import javax.annotation.PostConstruct;
  import java.io.IOException;
  import java.nio.file.Files;
  
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Value("${jwt.secret}")
      private Resource secretFile;
      private String key;
  
      @PostConstruct
      public void expandSecret() throws IOException {
          key = new String(Files.readAllBytes(secretFile.getFile().toPath()));
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .cors().and()
                  .csrf().disable()
                  .authorizeRequests()
                  .antMatchers(HttpMethod.POST, "/login").permitAll()
                  .anyRequest().authenticated()
                  .and()
                  .addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
      }
  
      @Bean
      public JwtAuthenticationFilter jwtAuthenticationFilter() {
          return new JwtAuthenticationFilter(key);
      }
  }
  </code></pre>