title: Error creating bean 'org.springframework.security.filterChains': Cannot resolve 'org.springframework.security.web.DefaultSecurityFilterChain#0'
body: <p>I am trying with OAuth2,am new to it,please help me out in solving this  </p>
  
  <pre><code>*org.springframework.web.context.ContextLoader initWebApplicationContext
      SEVERE: Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'clientCredentialsTokenEndpointFilter' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientCredentialsTokenEndpointFilter' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
          at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
          at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
          at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
          at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
          at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
          at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
          at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
          at org.apache.catalina.core.StandardService.start(StandardService.java:516)
          at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
          at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'clientCredentialsTokenEndpointFilter' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientCredentialsTokenEndpointFilter' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
          at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
          at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
          ... 41 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientCredentialsTokenEndpointFilter' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
          ... 55 more
      Caused by: java.lang.reflect.MalformedParameterizedTypeException
          at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
          at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.&lt;init&gt;(ParameterizedTypeImpl.java:53)
          at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
          at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
          at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
          at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
          at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
          at java.lang.reflect.Method.getGenericParameterTypes(Method.java:292)
          at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
          at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:114)
          at java.beans.MethodDescriptor.&lt;init&gt;(MethodDescriptor.java:72)
          at java.beans.MethodDescriptor.&lt;init&gt;(MethodDescriptor.java:56)
          at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1149)
          at java.beans.Introspector.getBeanInfo(Introspector.java:416)
          at java.beans.Introspector.getBeanInfo(Introspector.java:163)
          at java.beans.Introspector.getBeanInfo(Introspector.java:250)
          at java.beans.Introspector.&lt;init&gt;(Introspector.java:397)
          at java.beans.Introspector.getBeanInfo(Introspector.java:163)
          at org.springframework.beans.CachedIntrospectionResults.&lt;init&gt;(CachedIntrospectionResults.java:279)
          at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:189)
          at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:177)
          at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:236)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1368)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1347)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1209)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
          ... 61 more*
  </code></pre>
  
  <p>**WEB.xml****</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
   &lt;servlet&gt;  
    &lt;servlet-name&gt;spring&lt;/servlet-name&gt;  
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;  
   &lt;/servlet&gt;  
   &lt;servlet-mapping&gt;  
    &lt;servlet-name&gt;spring&lt;/servlet-name&gt;  
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;  
   &lt;/servlet-mapping&gt;  
   &lt;listener&gt;  
    &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;  
   &lt;/listener&gt;  
  
   &lt;context-param&gt;  
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;  
    &lt;param-value&gt;    
              /WEB-INF/spring-servlet.xml,    
              /WEB-INF/spring-security.xml  
          &lt;/param-value&gt;  
   &lt;/context-param&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;/web-app&gt;  
  </code></pre>
  
  <p><strong>Spring-security.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
      xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
          http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"&gt;
  
      &lt;sec:http pattern="/oauth/token" create-session="stateless"
          authentication-manager-ref="authenticationManager"&gt;
          &lt;sec:intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt;
          &lt;sec:anonymous enabled="false" /&gt;
          &lt;sec:http-basic entry-point-ref="clientAuthenticationEntryPoint" /&gt;
          &lt;sec:custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" /&gt;
          &lt;sec:access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
      &lt;/sec:http&gt;
  
      &lt;sec:http pattern="/protected/**" create-session="never"
          entry-point-ref="oauthAuthenticationEntryPoint"&gt;
          &lt;sec:anonymous enabled="false" /&gt;
          &lt;sec:intercept-url pattern="/protected/**" method="GET" access="IS_AUTHENTICATED_FULLY" /&gt;
          &lt;sec:custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" /&gt;
          &lt;sec:access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
      &lt;/sec:http&gt;
  
      &lt;bean id="oauthAuthenticationEntryPoint"
          class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="clientAuthenticationEntryPoint"
          class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
          &lt;property name="realmName" value="springsec/client" /&gt;
          &lt;property name="typeName" value="Basic" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="oauthAccessDeniedHandler"
          class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="clientCredentialsTokenEndpointFilter"
          class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter"&gt;
          &lt;property name="authenticationManager" ref="authenticationManager" /&gt;
          &lt;property name="sourceList" ref="authenticationManager" /&gt;
      &lt;/bean&gt;
  
      &lt;sec:authentication-manager alias="authenticationManager"&gt;
          &lt;sec:authentication-provider user-service-ref="clientDetailsUserService" /&gt;
      &lt;/sec:authentication-manager&gt;
  
      &lt;bean id="clientDetailsUserService"
          class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt;
          &lt;constructor-arg ref="clientDetails" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="clientDetails" class="in.AAAGuestServiceImpl"&gt;
          &lt;property name="id" value="webapi" /&gt;
          &lt;property name="secretKey" value="mycompanykey" /&gt;
      &lt;/bean&gt;
  
      &lt;sec:authentication-manager id="userAuthenticationManager"&gt;
          &lt;sec:authentication-provider ref="customUserAuthenticationProvider" /&gt;
      &lt;/sec:authentication-manager&gt;
  
      &lt;bean id="customUserAuthenticationProvider"
          class="in.AAAUserAuthenticationProvider"&gt;
      &lt;/bean&gt;
  
      &lt;oauth:authorization-server
          client-details-service-ref="clientDetails" token-services-ref="tokenServices"&gt;
          &lt;oauth:authorization-code /&gt;
          &lt;oauth:implicit/&gt;
          &lt;oauth:refresh-token/&gt;
          &lt;oauth:client-credentials /&gt;
          &lt;oauth:password authentication-manager-ref="userAuthenticationManager"/&gt;
      &lt;/oauth:authorization-server&gt;
  
      &lt;oauth:resource-server id="resourceServerFilter"
          resource-id="springsec" token-services-ref="tokenServices" /&gt;
  
      &lt;bean id="tokenStore"
          class="org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore" /&gt;
  
      &lt;bean id="tokenServices"
          class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"&gt;
          &lt;property name="tokenStore" ref="tokenStore" /&gt;
          &lt;property name="supportRefreshToken" value="true" /&gt;
          &lt;property name="accessTokenValiditySeconds" value="120"&gt;&lt;/property&gt;
          &lt;property name="clientDetailsService" ref="clientDetails" /&gt;
      &lt;/bean&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
      &lt;mvc:default-servlet-handler /&gt;
  
      &lt;context:annotation-config/&gt;
  
      &lt;bean id="MyResource" class="in.UserResource"&gt;&lt;/bean&gt;
      &lt;bean id="aaaProxy" class="in.AAAProxy"&gt;&lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>Used Jars</strong></p>
  
  <ul>
  <li>Spring security config 4.0.3 </li>
  <li>Spring security web 4.0.3</li>
  <li>Spring
  security core4.0.3</li>
  </ul>