tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 53863] New: Unable to override default servlet other than in main web.xml
Date Thu, 13 Sep 2012 03:44:28 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=53863

          Priority: P2
            Bug ID: 53863
          Assignee: dev@tomcat.apache.org
           Summary: Unable to override default servlet other than in main
                    web.xml
          Severity: critical
    Classification: Unclassified
                OS: All
          Reporter: fernando.ribeiro@upic.com.br
          Hardware: PC
            Status: NEW
           Version: 7.0.30
         Component: Catalina
           Product: Tomcat 7

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message