title: Error creating bean with name AuthenticationManager
body: <p>I am working on a Spring-MVC application which uses Spring-Security. In the application for login I have to use 2 login url's </p>
  
  <ul>
  <li>/j_spring_security_check_for_person
             AND</li>
  <li>/j_spring_security_check_for_group</li>
  </ul>
  
  <p>Both the login url's check against the database where I have implemented UserDetails and userDetailsService. To connect these both url's for login, I am using springSecurityFilterChain. Unfortunately, it is not working. I am at this problem since 2 days, I might be making some silly mistake. Kindly check the log and xml,</p>
  
  <p>Error Log :</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:239)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.security.config.authentication.AuthenticationManagerFactoryBean.getObject(AuthenticationManagerFactoryBean.java:28)
      at org.springframework.security.config.authentication.AuthenticationManagerFactoryBean.getObject(AuthenticationManagerFactoryBean.java:20)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
  </code></pre>
  
  <p>security-application-context.xml</p>
  
  <p></p>
  
  <pre><code>&lt;security:http create-session="ifRequired" use-expressions="true"
                 auto-config="true" disable-url-rewriting="true"&gt;
      &lt;security:form-login login-page="/" default-target-url="/canvas/list"
                 always-use-default-target="false"  authentication-failure-url="/denied.jsp" /&gt;
  &lt;security:logout logout-success-url="/" delete-cookies="JSESSIONID"
                       invalidate-session="true" logout-url="/j_spring_security_logout"/&gt;
  &lt;/security:http&gt;
  
  
  
  &lt;bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy"&gt;
          &lt;security:filter-chain-map path-type="ant"&gt;
              &lt;security:filter-chain pattern="/**" filters="authenticationProcessingFilterForPersonal, authenticationProcessingFilterForGroup"/&gt;
          &lt;/security:filter-chain-map&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="authenticationProcessingFilterForPersonal"
            class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"&gt;
          &lt;property name="authenticationManager" ref="authenticationManagerForPersonal"/&gt;
          &lt;property name="filterProcessesUrl" value="/j_spring_security_check_for_person" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="authenticationProcessingFilterForGroup"
            class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"&gt;
          &lt;property name="authenticationManager" ref="authenticationManagerForGroup"/&gt;
          &lt;property name="filterProcessesUrl" value="/j_spring_security_check_for_group"/&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="authenticationManagerForPersonal" class="org.springframework.security.authentication.ProviderManager"&gt;
      &lt;property name="providers"&gt;
              &lt;list&gt;
                  &lt;bean class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"&gt;
                      &lt;property name="userDetailsService"&gt;
                          &lt;ref bean="userDetailsService"/&gt;
                      &lt;/property&gt;
                      &lt;property name="passwordEncoder" ref="encoder"/&gt;
                  &lt;/bean&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
  
      &lt;bean id="authenticationManagerForGroup" class="org.springframework.security.authentication.ProviderManager"&gt;
          &lt;property name="providers"&gt;
              &lt;list&gt;
                  &lt;bean class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"&gt;
                      &lt;property name="userDetailsService"&gt;
                          &lt;ref bean="groupDetailsService"/&gt;
                      &lt;/property&gt;
                      &lt;property name="passwordEncoder" ref="encoder"/&gt;
                  &lt;/bean&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;security:authentication-manager alias="authenticationManager"&gt;
          &lt;security:authentication-provider ref="authenticationManagerForPersonal"/&gt;
          &lt;security:authentication-provider ref="authenticationManagerForGroup"/&gt;
      &lt;/security:authentication-manager&gt;
  
  
      &lt;beans:bean id="encoder"
                  class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"&gt;
          &lt;beans:constructor-arg name="strength" value="11" /&gt;
      &lt;/beans:bean&gt;
  </code></pre>
  
  <p>If I replace the authentication-manager code with the below snippet, I don't get an error, but the 2 login url's are not registered :</p>
  
  <pre><code>&lt;security:authentication-manager alias="authenticationManager"&gt;
              &lt;security:authentication-provider user-service-ref="userDetailsService"&gt;
                  &lt;security:password-encoder ref="encoder"/&gt;
              &lt;/security:authentication-provider&gt;
              &lt;security:authentication-provider user-service-ref="groupDetailsService"&gt;
                  &lt;security:password-encoder ref="encoder"/&gt;
              &lt;/security:authentication-provider&gt;
          &lt;/security:authentication-manager&gt;--&gt;
  </code></pre>