Created attachment 892492 [details] example project Description of problem: Mapping servlet to url pattern "/" does not work programmatically. I have encountered this issue when I was trying to bootstrap Spring WebMVC without XML configuration files. According to JSR-315 Servlet 3.0 specification (http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-eval-oth-JSpec/) section 12.2, url pattern "/" should override default servlet mapping. However, an application configured this way returns 404. Same issue was fixed in Tomcat 7.0.15 (https://issues.apache.org/bugzilla/show_bug.cgi?id=51278). Version-Release number of selected component (if applicable): EAP 6.3.0.ER3 How reproducible: Allways Steps to Reproduce: 1. Build & deploy attached example project Actual results: 404 Expected results: "Hello world!" Additional info: Default servlet is overridden when using web.xml. You can exclude SpringBootstrap class from project classpath, uncomment content of dispatcher-servlet.xml and web.xml and test expected behaviour.
Problem still occurs for EAP 6.3.0.ER10.
This issue can be reproduced in EAP 6.3 as well as 6.2.x. In order to reproduce this issue without even involving a simple web application can be used which tries to register a servlet to "/" dynamically using ServletContext API (inside ServletContextListener) something as following: +++++++++++++ @Override public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); System.out.println("\n\t Registering ServletA from inside the MyContextListener contextInitialized method."); Dynamic dynamic = context.addServlet("ServletA", ServletA.class); dynamic.addMapping("/"); System.out.println("\t ServletA is Registered with url-pattern /*"); } +++++++++++++
The attached simple servlet3 demo can be used to reproduce this issue: Deploy the attached WAR "Servlet3DemoA.war" then access the URL: http://localhost:8080/Servlet3DemoA/ Above should cause 404 Page not found error. In order to workaround this change the servlet mapping to something else (like /*) other than "/" ++++++++++ @Override public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); System.out.println("\n\t Registering ServletA from inside the MyContextListener contextInitialized method."); Dynamic dynamic = context.addServlet("ServletA", ServletA.class); dynamic.addMapping("/*"); System.out.println("\t ServletA is Registered with url-pattern /*"); } ++++++++++
Created attachment 935119 [details] Servlet3DemoA.war
I have no information to provide. I never felt it was important to fix this and the updates needed were a bit too extensive for the benefit, which is the reason it didn't get fixed.
Bartosz Baranowski <bbaranow> updated the status of jira JBMETA-385 to Coding In Progress
Re-acking after "qa_ack flag reset for and jboss-eap-6.4.0 and jboss-eap-6.4.z items" cleanup.
Jean-Frederic Clere <jfclere> updated the status of jira JBMETA-385 to Closed
Verified for EAP 6.4.1.CP.CR2.
I got it to work by adding a "*" to the servlet mapping -> "/*". Full example: public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return null; protected Class<?>[] getServletConfigClasses() { return new Class[] { AppWebConfig.class }; } @Override protected String[] getServletMappings() { return new String[] { "/*" }; } } My requests are then handlet by the DispatcherServlet.
Depending on your application that may or may not be a work around. The different is that all requests that do not match other mappings will be sent to the DispatcherServlet rather than returning a 404 directly. They will probably end up with a 404 anyway, but may not.
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.