Benito Ciaro Benito Ciaro - 2 years ago 307
Java Question

spring DelegatingFilterProxy can't find filter-name bean in web.xml when using AbstractSecurityWebApplicationInitializer

My web.xml looks like this



I commented out the JBoss
above to avoid an
because I am using a subclass of
elsewhere (from a mandatory library) which itself creates the root application context.

When I run this under tomcat7, I get a

SEVERE: Exception starting webContextFilter
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'webContextFilter' is defined

contains the appropriate
definitions, so that's not the problem.

I am guessing maybe the context loader from
is not yet started when DelegatingFilterProxy is created??

How can I fix this?

EDIT1: The
bean is in the right package, i.e. subpackage of the one listed in
, and the bean is defined as

public class WebContextFilter extends OncePerRequestFilter {
// ...

The bean is in a WEB-INF/lib/xyz.jar. This all used to work under tomcat6 when the JBoss resteasy
was uncommented in web.xml.

EDIT2: Perhaps my question boils down to this: when using
to create the root context, how do I specify additional filters, since the ones in web.xml don't seem to work?

Answer Source

The problem was that the applicationContext.xml was not being read, so I added @ImportResource annotation to the SecurityConfig class definition.

public class SecurityConfig extends WebSecurityConfigurerAdapter {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download