title: No bean named authenticationManager
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5090890/getting-error-org-springframework-beans-factory-nosuchbeandefinitionexception-n">Getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘springSecurityFilterChain’ is defined</a>  </p>
  </blockquote>
  
  
  
  <p>In my Spring Application, I keep getting this error:</p>
  
  <pre><code>No bean named 'org.springframework.security.authenticationManager' is defined: Did you forget to add a gobal &lt;authentication-manager&gt; element to your configuration (with child &lt;authentication-provider&gt; elements)? Alternatively you can use the authentication-manager-ref attribute on your &lt;http&gt; and &lt;global-method-security&gt; elements.
  </code></pre>
  
  <p>In my Spring Security context xml file, I have defined the following:</p>
  
  <pre><code>&lt;beans:bean id="myUserDetailsService" class="com.myProject.core.security.MyUserDetailsService" /&gt;
  
  &lt;beans:bean id="encoder" class="com.myProject.core.security.HmacPasswordEncoder" /&gt;
  
  &lt;authentication-manager id="clientAuthenticationManager" &gt;
      &lt;authentication-provider user-service-ref="myUserDetailsService"&gt;
          &lt;password-encoder ref="encoder" /&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>Any ideas why its complaining, when I have clearly defined my authentication-manager and authentication-provider?</p>
  
  <p>Note: this might help, its a more descriptive error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with 
  name 'org.springframework.security.filterChains': Cannot resolve reference to bean
  'org.springframework.security.web.DefaultSecurityFilterChain#2' while setting bean
  property 'sourceList' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2':
  Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0'
  while setting constructor argument with key [1]; nested exception is
  org.springframework.beans.factory.BeanCreationException: Error creating bean with
  name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0':
  Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0'
  while setting bean property 'authenticationManager'; nested exception is
  org.springframework.beans.factory.BeanCreationException: Error creating bean with
  name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve
  reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'
  while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':
  FactoryBean threw exception on object creation; nested exception is
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named
  'org.springframework.security.authenticationManager' is defined: Did you forget to
  add a gobal &lt;authentication-manager&gt; element to your configuration (with child
  &lt;authentication-provider&gt; elements)? Alternatively you can use the authentication-manager-ref
  attribute on your &lt;http&gt; and &lt;global-method-security&gt; elements.
  </code></pre>