No bean named 'springSecurityFilterChain' is defined

In this article, we are discussing the spring org.springframework.beans. factory. NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined.
This exception is very common if you are the beginner for spring security.

Here is the complete Exception Stack Trace:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined at at at at at at org.springframework.web.filter.DelegatingFilterProxy.initDelegate( at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean( at org.springframework.web.filter.GenericFilterBean.init( at org.apache.catalina.core.ApplicationFilterConfig.initFilter( at org.apache.catalina.core.ApplicationFilterConfig.getFilter( at org.apache.catalina.core.ApplicationFilterConfig.<init>( at org.apache.catalina.core.StandardContext.filterStart( at org.apache.catalina.core.StandardContext.startInternal( at org.apache.catalina.util.LifecycleBase.start( at org.apache.catalina.core.ContainerBase.addChildInternal( at org.apache.catalina.core.ContainerBase.addChild( at org.apache.catalina.core.StandardHost.addChild( at org.apache.catalina.startup.HostConfig.deployDescriptor( at org.apache.catalina.startup.HostConfig$ at java.util.concurrent.Executors$ at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at

Cause Of Exception:

The cause of this exception is that ? Spring Security looks for a bean named springSecurityFilterChain (by default), and cannot find it in your application classpath.
This bean is required by the main Spring Security Filter ? the DelegatingFilterProxy ? defined in the web.xml:

<filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

This is just a proxy that delegates all its logic or incoming request to the springSecurityFilterChain bean.


The most common reason this bean is missing from the context is that the security XML configuration has no element defined:

<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="" xmlns:xsi="" xmlns:beans="" xmlns:sec="" xsi:schemaLocation=""> </beans:beans>

If the XML configuration is using the security namespace as the example above, then declaring a simple element will ensure that the filter bean is created and everything starts up correctly:

<http auto-config='true'> <intercept-url pattern="/**" access="ROLE_USER" /> </http>

Another possible reason is that the security configuration is not imported at all into the overall context of the web application.

If the security XML config file is named securityConfig.xml, make sure the resource is imported in the main spring configuration file

Like this we have to import that securityConfig.xml file in java config class


Or in XML:

<import resource="classpath:securityConfig.xml" />

Finally, the default name of the filter bean can be changed in the web.xml. It is usually used as an existing Filter with Spring Security:

<filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> <init-param> <param-name>targetBeanName</param-name> <param-value>customFilter</param-value> </init-param> </filter>


In this article we discussed about the Spring Security problem, the missing filter chain bean and showed the solutions to this common issue.

If you have any other doubt, feel free to ask us in the comments section, we will try to solve it too.

Solution Worked 0 UpvotesUpvote
Solution Didn't Worked 0 DownvotesDownvote