title: Spring: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
body: <p>I don't know why I keep getting this error repeatedly when ever I launch my spring application. This is the stacktrace of the error</p>
  
  <pre><code> SEVERE: Exception starting filter springSecurityFilterChain
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:698)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1174)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:283)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:201)
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1051)
      at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326)
      at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235)
      at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199)
      at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
      at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:105)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4574)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5193)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>This is my web.xml file where I have defined the springsecurityfilterchain</p>
  
  
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;
                org.springframework.web.filter.DelegatingFilterProxy
      &lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>In a file called appconfig-security.xml I have this configuration</p>
  
  <pre><code>&lt;http auto-config="true"&gt;
          &lt;form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password"/&gt;
          &lt;logout logout-success-url="/login?logout" /&gt;
      &lt;/http&gt;
  </code></pre>
  
  <p><strong>EDITTED TO ADD MORE INFO</strong></p>
  
  <p>this is my appconfig-mvc.xml where I have definitions such as internalviewresolver and other kind of configuration</p>
  
  <pre><code>&lt;!-- DataSource definition --&gt;
      &lt;import resource="appconfig-data.xml" /&gt;
  
  
      &lt;!-- added this line of code --&gt;
      &lt;mvc:annotation-driven/&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/"/&gt;
      &lt;!-- ends here --&gt;
  
  
      &lt;!-- Mapping Controllers --&gt;
      &lt;context:annotation-config /&gt;
  
      &lt;context:component-scan base-package="com.springfoundation" /&gt;
  
      &lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
          &lt;property name="basenames"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath:validation&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;!-- removed internal view resolver from this file --&gt;
  &lt;!-- JSP Templates and Pages --&gt;
      &lt;bean id="jspViewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="viewClass"
              value="org.springframework.web.servlet.view.JstlView" /&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>this is my appconf-data.xml file where I have configurations such as database connections </p>
  
  <pre><code>&lt;!-- Configure the data source bean --&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;
          &lt;property name="url" value="${jdbc.url}"/&gt;
          &lt;property name="username" value="${jdbc.username}"/&gt;
          &lt;property name="password" value="${jdbc.password}"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Configure the entity manager factory bean --&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="packagesToScan" value="com.springfoundation.model"/&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
          &lt;/property&gt;
          &lt;property name="jpaProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- Configure the transaction manager bean --&gt;
      &lt;bean id="transactionManager"
            class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Enable annotation driven transaction management --&gt;
      &lt;tx:annotation-driven/&gt;
  
      &lt;!--
        Configure Spring Data JPA and set the base package of the
        repository interfaces
      --&gt;
  
      &lt;jpa:repositories base-package="com.springfoundation.repository"/&gt;
  </code></pre>
  
  <p>this is how I am importing my configuration xml files defined in spring folder under resource to my web.xml file and also showing the <strong>complete content</strong> in my web.xml file</p>
  
  <pre><code> &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt;
      &lt;description&gt;This is a template for a simple and informational Login and CRUD WebAPP.&lt;/description&gt;
  
      &lt;!-- - Location of the XML file that defines the root application context. 
           - Applied by ContextLoaderListener. --&gt;
  
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              classpath:spring/appconfig-mvc.xml, 
              classpath:spring/appconfig-security.xml, 
              classpath:spring/appconfig-root.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  
  
  &lt;!-- 
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              /WEB-INF/appconfig-root.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt; --&gt;
  &lt;!-- 
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              classpath:spring/main-dispatcher-servlet.xml, 
              classpath:spring/spring-security-config.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  --&gt;
  
  
  
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Servlet that dispatch request from Controllers --&gt;
  &lt;!--  
      &lt;servlet&gt;
          &lt;servlet-name&gt;springSimple&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:spring/mvc-dispatcher-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      --&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;springSimple&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:spring/appconfig-mvc.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;springSimple&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
  
      &lt;!-- Spring Security --&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;
                    org.springframework.web.filter.DelegatingFilterProxy
          &lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;!-- General Configurations --&gt;
  
      &lt;welcome-file-list&gt;
          &lt;!-- First Page load --&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;error-page&gt;
          &lt;!-- No found page --&gt;
          &lt;error-code&gt;404&lt;/error-code&gt;
          &lt;location&gt;/WEB-INF/jsp/errors/404.jsp&lt;/location&gt;
      &lt;/error-page&gt;
  </code></pre>
  
  <p>I dont know why I keep getting this error.</p>