title: No WebApplicationContext found not in DispatcherServlet requested and no ContextLoaderListener registered
body: <p>I found several questions with same issue except for the fact that I am using an embedded tomcat.</p>
  
  <p>I tried all answers I found, most of them related to ContextLoaderListener and dependencies. </p>
  
  <p>I noted that when I builded the application after "mvn clean package" there are several warnnings about duplication but honestly I don't think this is the issue. I believe there is some issue between embedded Tomcat configuration and the context.</p>
  
  <p>logs during buiding</p>
  
  <pre><code>C:\STS\wsRestTemplate\TestDeployment&gt;mvn clean package
  ...
  [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ TestDeployment ---
  [INFO] Building jar: C:\STS\wsRestTemplate\TestDeployment\target\embeddedApp.jar
  
  [INFO]
  [INFO] --- appassembler-maven-plugin:1.10:assemble (default) @ TestDeployment --
  -
  [WARNING] The usage of program name (App) is deprecated. Please use program.id i
  nstead.
  [INFO] Installing artifact C:\Users\e049447\.m2\repository\org\springframework\s
  pring-web\4.2.5.RELEASE\spring-web-4.2.5.RELEASE.jar to C:\STS\wsRestTemplate\Te
  stDeployment\target\repo\org\springframework\spring-web\4.2.5.RELEASE\spring-web
  -4.2.5.RELEASE.jar
  [INFO] Installing artifact C:\Users\e049447\.m2\repository\org\springframework\s
  pring-aop\4.2.5.RELEASE\spring-aop-4.2.5.RELEASE.jar to C:\STS\wsRestTemplate\Te
  stDeployment\target\repo\org\springframework\spring-aop\4.2.5.RELEASE\spring-aop
  -4.2.5.RELEASE.jar
  ...
  [INFO] Installing artifact C:\STS\wsRestTemplate\TestDeployment\target\embeddedA
  pp.jar to C:\STS\wsRestTemplate\TestDeployment\target\repo\com\mastercard\ictt\b
  atchs\TestDeployment\0.0.1-SNAPSHOT\TestDeployment-0.0.1-SNAPSHOT.jar
  [INFO]
  [INFO] --- maven-shade-plugin:1.3.3:shade (default) @ TestDeployment ---
  [INFO] Including org.springframework:spring-web:jar:4.2.5.RELEASE in the shaded
  jar.
  [INFO] Including org.springframework:spring-aop:jar:4.2.5.RELEASE in the shaded
  ...[INFO] Including commons-io:commons-io:jar:2.2 in the shaded jar.
  [INFO] Including javax.servlet:javax.servlet-api:jar:3.0.1 in the shaded jar.
  [WARNING] We have a duplicate org/apache/jasper/Constants.class in C:\Users\e049
  447\.m2\repository\org\apache\tomcat\tomcat-jasper\8.0.32\tomcat-jasper-8.0.32.j
  ar
  [WARNING] We have a duplicate org/apache/jasper/EmbeddedServletOptions.class in
  C:\Users\e049447\.m2\repository\org\apache\tomcat\tomcat-jasper\8.0.32\tomcat-ja
  sper-8.0.32.jar
  [WARNING] We have a duplicate org/apache/jasper/JasperException.class in C:\User
  s\e049447\.m2\repository\org\apache\tomcat\tomcat-jasper\8.0.32\tomcat-jasper-8.
  0.32.jar
  [WARNING] We have a duplicate org/apache/jasper/JspC.class in C:\Users\e049447\.
  m2\repository\org\apache\tomcat\tomcat-jasper\8.0.32\tomcat-jasper-8.0.32.jar
  [WARNING] We have a duplicate org/apache/jasper/JspCompilationContext.class in C
  :\Users\e049447\.m2\repository\org\apache\tomcat\tomcat-jasper\8.0.32\tomcat-jas
  per-8.0.32.jar
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6WaAE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6WaAE.jpg" alt="Project Structure and Libs Dependencies"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ZgN80.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZgN80.jpg" alt="The error"></a></p>
  
  <p>App-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
     http://www.springframework.org/schema/beans    
     http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-4.2.xsd"&gt;
  
     &lt;context:component-scan base-package="com.mycomp.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;
  &lt;/beans&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
  
         &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt;
  
         &lt;!-- I tried add COntextLoader Listener and explicitly point to App-servlet.xml but I don~t think it is necessary
         By the way, same error with it or without --&gt;
         &lt;!-- listener&gt;
                &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
         &lt;/listener&gt;
  
         &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/App-servlet.xml&lt;/param-value&gt;
                &lt;/context-param --&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;welcome-file-list&gt;
                &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
         &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>static main</p>
  
  <pre><code>import org.apache.catalina.LifecycleException;
  import org.apache.catalina.startup.Tomcat;
  
  
  public class App
  {
      public static void main( String[] args ) throws LifecycleException
      {
                Tomcat tomcat = new Tomcat();
  
                tomcat.setPort(8080);
                tomcat.setBaseDir("C\\temp");
                tomcat.addWebapp(tomcat.getHost(), "/", "C:\\temp\\");//
                tomcat.start();
                tomcat.getServer().await();
      }
  }
  </code></pre>
  
  <p>Index.jsp (if I comment all the lines below and I add a simple Hello Word string it will work as wellcome page)</p>
  
  <pre><code>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Uploading a file.. &lt;/h2&gt;
        &lt;form:form method="POST" action="uploadFile" enctype="multipart/form-data"&gt;
                Upload your file please:
                &lt;input type="file" name="file" /&gt;
                &lt;input type="text" name="name"&gt;
                &lt;input type="submit" value="Upload" /&gt;
                &lt;form:errors path="file" cssStyle="color: #ff0000;" /&gt;
         &lt;/form:form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>@Controller
  public class FileUploadController {
  
  
         @RequestMapping(value="/upload",method = RequestMethod.GET)
         public String printHello(ModelMap model) {
               return "index";
            }
  </code></pre>