Hello,
Are there examples or other references on how to configure the new WebApplicationInitializer introduced in Spring 3.1 and Spring Security? We are writing a greenfield application and would like to be as bleeding edge as possible
What I have below is functional with our new beans:
The tomcat 7.0 startup log is complaining that the filter is not found.Code:public class Initializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext sc) { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); root.scan("com.hadron.ui"); root.setConfigLocation("classpath:/WEB-INF/applicationContext-security.xml"); // Manages the life cycle of the root application context sc.addListener(new ContextLoaderListener(root)); // spring security DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy("springSecurityFilterChain"); FilterRegistration fr = sc.addFilter("springSecurityFilterChain", delegatingFilterProxy); fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/**"); ServletRegistration.Dynamic dispatcher = sc.addServlet("mvcServlet", new DispatcherServlet(new GenericWebApplicationContext())); dispatcher.setLoadOnStartup(1); Set<String> mappingConflicts = dispatcher.addMapping("/mvc/*"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException("'mvcServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); } } }
ThanksCode:DEBUG: org.springframework.web.filter.HiddenHttpMethodFilter - Filter 'hiddenHttpMethodFilter' configured successfully DEBUG: org.springframework.web.filter.DelegatingFilterProxy - Initializing filter 'springSecurityFilterChain' Sep 15, 2011 7:00:52 AM org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter springSecurityFilterChain org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined



Reply With Quote