title: Spring boot WAR runs from maven, not from command line?
body: <p><a href="https://stackoverflow.com/questions/40148829/whats-the-difference-of-mvn-spring-bootrun-and-application-main">I checked this question</a>, but the answer (while interesting) basically says "don't use WAR packaging" which is not an option here.</p>
  
  <p>I have a Spring Boot repackaged WAR which uses embedded Tomcat (Spring Boot 1.5.3.RELEASE, embedded Tomcat 8.5.14).    The repackaged app runs fine using the <code>mvn spring-boot:run</code> command but when I try to run it using `java -jar target\mywar.war'  I get this:</p>
  
  <pre><code>java.io.FileNotFoundException: file:\C:\work\spring-boot\target\spring-boot-mywar.war!\WEB-INF\classes!\mywar.war (The filename, directory name, or volume label syntax is incorrect)
  </code></pre>
  
  <p>This is caused when Spring Boot tries to load the context for the "wrapped" war:</p>
  
  <pre><code>Context context = tomcat.addWebapp("/mywar", Thread.currentThread().getContextClassLoader().getResource("mywar.war").getPath());
  </code></pre>
  
  <p>The actual error takes place inside the embedded Tomcat class:</p>
  
  <pre><code>private URL getWebappConfigFileFromJar(File docBase, String contextName) {
      URL result = null;
      try (JarFile jar = new JarFile(docBase)) {
          JarEntry entry = jar.getJarEntry(Constants.ApplicationContextXml);
          if (entry != null) {
              result = UriUtil.buildJarUrl(docBase, Constants.ApplicationContextXml);
          }
      } catch (IOException e) {
          Logger.getLogger(getLoggerName(getHost(), contextName)).log(Level.WARNING,
                  "Unable to determine web application context.xml " + docBase, e);
      }
      return result;
  }
  </code></pre>
  
  <p>The operation <code>new JarFile(docBase)</code> throws the <code>FileNotFoundException</code>.</p>
  
  <p>This works fine when the Maven <code>spring-boot:run</code> goal is used, so I feel that the basic structure is sound - I think there's some classpath issue or something that's keeping it from working.   </p>
  
  <p>Does anyone have any suggestion for duplicating the environment of <code>spring-boot:run</code> on the command line when using WAR packaging?</p>