java.lang.IllegalArgumentException: The main resource set specified [<jar>] is not valid in Embedded Tomcat
<p>How to fix the error:</p>

<pre><code>java.lang.IllegalArgumentException: The main resource set specified [C:\temp\myApp.jar] is not valid
</code></pre>

<p>in an Embedded Tomcat application?</p>

<p>I believe I am doing something wrong with the context path but I couldn't figure out how to set it up. Starting the application throw Eclipse work as expected but when I try to run from command prompt I get the error below. I pasted below the two main ways I have tried, App3 and App4 (the error is the same via command prompt). I guess it is not showing error in Eclipse because there must be some pre-defined parameter related to Context that it is making the application run on Eclipse but crashing while triggered from Command Prompt. I have already checked and I am using exactly same JDK.</p>

<p>I believe the problem is with context because, even when it runs throw Eclipse with second tentative (App4), if I check C:\temp, there is no war at all over there.</p>

<p>One tentative (without setAppBase):</p>

<pre><code>import java.io.File;
import java.net.URISyntaxException;
import javax.servlet.ServletException;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;


public class App3 {
       public static void main(String[] args) throws ServletException,
                     LifecycleException, URISyntaxException {
              String runningJarPath = App.class.getProtectionDomain().getCodeSource()                           .getLocation().toURI().getPath().replaceAll("\\\\", "/");

              String contextPath = "/";
              File rootF = new File(runningJarPath);

              Tomcat tomcat = new Tomcat();
              tomcat.setPort(8080);
              tomcat.setBaseDir(".");
              tomcat.addWebapp(contextPath, rootF.getAbsolutePath());

              tomcat.start();
              tomcat.getServer().await();
       }
}
</code></pre>

<p>Other tentative (with setAppBase to especific folder):</p>

<pre><code>    import java.io.File;
    import java.net.URISyntaxException;
    import javax.servlet.ServletException;
    import org.apache.catalina.LifecycleException;
    import org.apache.catalina.startup.Tomcat;

    public class App4 {
           public static void main(String[] args) throws URISyntaxException,
                         ServletException, LifecycleException {
                  String runningJarPath = App4.class.getProtectionDomain()
                              .getCodeSource().getLocation().toURI().getPath()
                               .replaceAll("\\\\", "/");
                  String contextPath = "/";
                  File rootF = new File(runningJarPath);
                  Tomcat tomcat = new Tomcat();
                  tomcat.setPort(8080);
                  tomcat.setBaseDir("C\\temp");
//the next line was added along with ***Edited 2
                  tomcat.addWebapp(tomcat.getHost(), "/App", "C:\\temp\\");
//the next two lines commented was commented along with ***Edited 2
                  //tomcat.addWebapp(contextPath, rootF.getAbsolutePath());
                  tomcat.getHost().setAppBase("C\\temp");
                  tomcat.start();
                  //tomcat.addWebapp(tomcat.getHost(), "/App", "C:\\temp\\");//
                  tomcat.getServer().await();
           }
    }
</code></pre>

<p>web.xml</p>

<pre><code>&lt;!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" &gt;

&lt;web-app &gt;

   &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt;
   &lt;servlet&gt;
      &lt;servlet-name&gt;App&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
         org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
   &lt;/servlet&gt;

   &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;App&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
&lt;/web-app&gt;
</code></pre>

<p>Logs from Eclipse:</p>

<pre><code>Mar 02, 2016 3:11:25 PM org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
Mar 02, 2016 3:11:26 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 02, 2016 3:11:27 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 02, 2016 3:11:27 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Mar 02, 2016 3:11:27 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.32
Mar 02, 2016 3:11:27 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Mar 02, 2016 3:11:38 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 02, 2016 3:11:39 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Mar 02, 2016 3:11:39 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [203] milliseconds.
Mar 02, 2016 3:11:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'App'
Mar 02, 2016 3:11:40 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'App': initialization started
Mar 02, 2016 3:11:40 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'App-servlet': startup date [Wed Mar 02 15:11:40 CST 2016]; root of context hierarchy
Mar 02, 2016 3:11:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/App-servlet.xml]
Mar 02, 2016 3:11:41 PM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/upload] onto handler 'fileUploadController'

...

Mar 02, 2016 3:11:41 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'App': initialization completed in 1609 ms
Mar 02, 2016 3:11:41 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 02, 2016 3:11:45 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 02, 2016 3:11:45 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
</code></pre>

<p>Error from command prompt:</p>

<pre><code>C:\Program Files\Java\jdk1.8.0_45\jre&gt;java -jar C:\temp\myApp.jar
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
Mar 02, 2016 3:15:55 PM org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and d
o not end with a '/'. The path [/] does not meet these criteria and has been changed to []
Mar 02, 2016 3:15:56 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 02, 2016 3:15:56 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

INFO: Using a shared selector for servlet write/read
Mar 02, 2016 3:15:56 PM org.apache.catalina.core.StandardService startInternal

INFO: Starting service Tomcat
Mar 02, 2016 3:15:56 PM org.apache.catalina.core.StandardEngine startInternal

INFO: Starting Servlet Engine: Apache Tomcat/8.0.32
Mar 02, 2016 3:15:57 PM org.apache.catalina.core.ContainerBase startInternal

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:

Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
</code></pre>

<p>POM.xml:</p>

<pre><code>&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.myCompany.myApp.batchs&lt;/groupId&gt;
       &lt;artifactId&gt;AuthFileUpload&lt;/artifactId&gt;
       &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
       &lt;packaging&gt;jar&lt;/packaging&gt;
       &lt;name&gt;AuthFileUpload&lt;/name&gt;
       &lt;url&gt;http://maven.apache.org&lt;/url&gt;
       &lt;properties&gt;
              &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
              &lt;tomcat.version&gt;8.0.32&lt;/tomcat.version&gt;
              &lt;java.version&gt;1.8&lt;/java.version&gt;
              &lt;maven.compiler.plugin.version&gt;2.1&lt;/maven.compiler.plugin.version&gt;
              &lt;spring.version&gt;4.2.5.RELEASE&lt;/spring.version&gt;
       &lt;/properties&gt;


       &lt;dependencies&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                     &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
                     &lt;version&gt;${spring.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-embed-core&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-embed-logging-juli&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-jasper-el&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                     &lt;artifactId&gt;tomcat-jsp-api&lt;/artifactId&gt;
                     &lt;version&gt;${tomcat.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                     &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
                     &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
                     &lt;version&gt;1.3.1&lt;/version&gt;
              &lt;/dependency&gt;


       &lt;/dependencies&gt;
       &lt;build&gt;
              &lt;finalName&gt;embeddedApp&lt;/finalName&gt;
              &lt;plugins&gt;
                     &lt;plugin&gt;
                           &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                           &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                           &lt;version&gt;${maven.compiler.plugin.version}&lt;/version&gt;
                           &lt;configuration&gt;
                                  &lt;source&gt;${java.version}&lt;/source&gt;
                                  &lt;target&gt;${java.version}&lt;/target&gt;
                           &lt;/configuration&gt;
                     &lt;/plugin&gt;

                     &lt;plugin&gt;
                           &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                           &lt;artifactId&gt;appassembler-maven-plugin&lt;/artifactId&gt;
                           &lt;version&gt;1.1.1&lt;/version&gt;
                           &lt;configuration&gt;
&lt;assembleDirectory&gt;target&lt;/assembleDirectory&gt;
                                  &lt;programs&gt;
                                         &lt;program&gt;
                                                &lt;mainClass&gt;com.myCompany.myApp.batchs.AuthFileUpload.App4&lt;/mainClass&gt;

                                                &lt;name&gt;App4&lt;/name&gt;

                                         &lt;/program&gt;
                                  &lt;/programs&gt;
                           &lt;/configuration&gt;
                           &lt;executions&gt;
                                  &lt;execution&gt;
                                         &lt;phase&gt;package&lt;/phase&gt;
                                         &lt;goals&gt;
                                                &lt;goal&gt;assemble&lt;/goal&gt;
                                         &lt;/goals&gt;
                                  &lt;/execution&gt;
                           &lt;/executions&gt;
                     &lt;/plugin&gt;
              &lt;/plugins&gt;
       &lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>*** Edited 1 - the entire log relate to the tentative 1 (App3)</p>

<pre><code>C:\Program Files\Java\jdk1.8.0_45\jre&gt;java -jar C:\temp\myApp.jar
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
Mar 02, 2016 7:53:13 PM org.apache.catalina.core.StandardContext setPath
WARNING: A context path must either be an empty string or start with a '/' and d
o not end with a '/'. The path [/] does not meet these criteria and has been cha
nged to []
Mar 02, 2016 7:53:14 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 02, 2016 7:53:14 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSele
ctor
INFO: Using a shared selector for servlet write/read
Mar 02, 2016 7:53:14 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Mar 02, 2016 7:53:14 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.32
Mar 02, 2016 7:53:15 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:
Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].Stand
ardContext[]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:916)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
:871)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1408)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1398)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [St
andardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [or
g.apache.catalina.webresources.StandardRoot@791d05e7]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardConte
xt.java:4928)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5058)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 6 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [
C:\temp\myApp.jar] is not valid
        at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(S
tandardRoot.java:723)
        at org.apache.catalina.webresources.StandardRoot.startInternal(StandardR
oot.java:684)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 9 more

Mar 02, 2016 7:53:15 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException:
Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:916)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.
java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.StandardService.startInternal(StandardServic
e.java:441)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
java:769)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:345)
        at com.MyCompany.myApp.batchs.AuthFileUpload.App3.main(App3.java:28)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [St
andardEngine[Tomcat].StandardHost[localhost]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1408)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
java:1398)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: A child container failed duri
ng start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:924)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java
:871)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 6 more

Exception in thread "main" org.apache.catalina.LifecycleException: Failed to sta
rt component [StandardServer[-1]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:345)
        at com.MyCompany.myApp.batchs.AuthFileUpload.App3.main(App3.java:28)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [St
andardService[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.
java:769)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 2 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [St
andardEngine[Tomcat]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
        at org.apache.catalina.core.StandardService.startInternal(StandardServic
e.java:441)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 4 more
Caused by: org.apache.catalina.LifecycleException: A child container failed duri
ng start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja
va:924)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.
java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        ... 6 more

C:\Program Files\Java\jdk1.8.0_45\jre&gt;
</code></pre>

<p>*** edited 2 entire log relate to tentative 2 (App4)</p>

<pre><code>C:\Program Files\Java\jdk1.8.0_45\jre&gt;java -jar C:\temp\myApp.jar
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar
Mar 02, 2016 8:04:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 02, 2016 8:04:09 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSele
ctor
INFO: Using a shared selector for servlet write/read
Mar 02, 2016 8:04:09 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Mar 02, 2016 8:04:09 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.32
Mar 02, 2016 8:04:10 PM org.apache.catalina.core.StandardContext postWorkDirecto
ry
WARNING: Failed to create work directory [C:\Program Files\Java\jdk1.8.0_45\jre\
C\temp\work\Tomcat\localhost\App] for context [/App]
Mar 02, 2016 8:04:10 PM org.apache.catalina.startup.ContextConfig getDefaultWebX
mlFragment
INFO: No global web.xml found
Mar 02, 2016 8:04:18 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 02, 2016 8:04:18 PM org.apache.catalina.util.SessionIdGeneratorBase createSe
cureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRN
G] took [187] milliseconds.
Mar 02, 2016 8:04:18 PM org.apache.jasper.EmbeddedServletOptions &lt;init&gt;
SEVERE: The scratchDir you specified: C:\Program Files\Java\jdk1.8.0_45\jre\C\te
mp\work\Tomcat\localhost\App is unusable.
Mar 02, 2016 8:04:18 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
</code></pre>

<p>*** Added in 2016/03/03 at 4:30PM (Brasilia Time UTC-03:00)</p>

<pre><code>   public static void main(String[] args) throws IOException,
                 ServletException, LifecycleException {
          Tomcat tomcat = new Tomcat();

          tomcat.setPort(8080);

          String strBaseDIr = "C:\\temp\\"; // Files.createTempDirectory("tomcat-basedir").toString();
          tomcat.setBaseDir(strBaseDIr);

          // Option 1 - default-doc-base - doesn't work even in Eclipse
          // String strWebApp =
          // Files.createTempDirectory("default-doc-base").toString();
          // strWebApp is C:\Users\myUser\AppData\Local\Temp
          // tomcat.addWebapp("", strWebApp);

          // Option 2 - it works in Eclipse but "HTTP Status 404 - /upload" when
          // started from java -jar
          // tomcat.addWebapp("",
          // "C:\\STS\\wsRestTemplate\\AuthFileUpload\\target\\classes");

          // Option 3 - passing empty path as you wrote
          // "... the trick is to pass an empty folder ..."
          // same issue - "HTTP Status 404 - /upload" when started from java -jar
          // tomcat.addWebapp("", "");

          // Option 4 - the executable jar was placed in C:\Temp
          // same issue - "HTTP Status 404 - /upload" when started from java -jar
          tomcat.addWebapp("/", "C:\\temp\\myApp.jar");

          tomcat.start();
          tomcat.getServer().await();

   }
</code></pre>

<p>App-servlet.xml</p>

<pre><code>&lt;context:component-scan base-package="com.mycompany.myapp.batchs.AuthFileUpload" /&gt;

&lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
 &lt;property name="prefix" value="/WEB-INF/" /&gt;
 &lt;property name="suffix" value=".jsp" /&gt;
&lt;/bean&gt;

&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" /&gt;
</code></pre>