An implementation of ServletContainerInitializer can't add a mapping to "/" because the default servlet is loaded first, as first reported in 51278: public final class SampleServletContainerInitializer implements ServletContainerInitializer { public void onStartup(final Set<Class<?>> c, final ServletContext ctx) throws ServletException { final XmlWebApplicationContext appCtx = new XmlWebApplicationContext(); appCtx.setConfigLocation("/WEB-INF/DispatcherServlet-servlet.xml"); final ServletRegistration.Dynamic dispatcher = ctx.addServlet("DispatcherServlet", new DispatcherServlet(appCtx)); dispatcher.setLoadOnStartup(1); final Set<String> conflictSet = dispatcher.addMapping("/"); for (final String conflict : conflictSet) out.println(conflict); // prints "/" } } A test case follows attached.
Created attachment 29366 [details] testcase
There is a bug here but it was hard work to find. The lack of key information provided with the test case did not help. For future reference, the following information would have saved some considerable time: - Maven version required (build failed with 2.2.1, worked with 3.0.4) - Steps to execute the test case - Make clear the issue was with embedded mode The best test cases are as small as possible and are written as unit tests (of which plenty of examples exist in the code base - including ones that use SCIs). The bug was that the implicit servlets (JSP, default) when added in embedded mode were not marked as override-able. This has been fixed in trunk and 7.0.x and will be included in 7.0.31 onwards.
I will make sure future tickets provide better info. Thanks.