title: WebApplicationInitializer isn't detected
body: <p>On my small Spring MVC project I can configure dispatcher using web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
  
      &lt;init-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;myweb.ApplicationConfig&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>I would like to remove the config above from web.xml and I try to use this class:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  public class ApplicationInitializer implements WebApplicationInitializer {
      protected Logger logger = Logger.getLogger(ApplicationInitializer.class);
  
      @Override
      public void onStartup(ServletContext servletContext) throws ServletException {
          logger.info("Application initialization ...");
  
          AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
          context.setConfigLocation("myweb");
  
          servletContext.addListener(new ContextLoaderListener(context));
  
          ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
          dispatcher.setLoadOnStartup(1);
          dispatcher.addMapping("/");
  
          logger.info("Application initialized");
      }
  }
  </code></pre>
  
  <p>Unfortunately the code above won't called and I have no idea why. Could somebody help me what could be the reason?</p>
  
  <p>Environment: JBoss EAP 6.4, spring is in lib folder inside a WAR which is in an EAR</p>
  
  <hr>
  
  <p>It should work this way if I am right:</p>
  
  <p>the <strong>SpringServletContainerInitializer</strong> class in <em>Spring</em> implements <strong>ServletContainerInitializer</strong> and has annotation <em>@HandlesTypes(WebApplicationInitializer.class)</em>. In the <em>META-INF/services</em> folder in <em>spring-web.jar</em> it is declared that this class is a service, should be called. It is a <strong>Servlet 3.0</strong> feature to call this class with classes as parameter which implements <strong>WebApplicationInitializer</strong> interface. The problem is that <strong>SpringServletContainerInitializer</strong> isn't called by the web-container and I have no idea why.</p>