No bean named authenticationManager

user1007895 :

Possible Duplicate:
Getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘springSecurityFilterChain’ is defined

In my Spring Application, I keep getting this error:

No bean named 'org.springframework.security.authenticationManager' is defined: Did you forget to add a gobal <authentication-manager> element to your configuration (with child <authentication-provider> elements)? Alternatively you can use the authentication-manager-ref attribute on your <http> and <global-method-security> elements.

In my Spring Security context xml file, I have defined the following:

<beans:bean id="myUserDetailsService" class="com.myProject.core.security.MyUserDetailsService" />

<beans:bean id="encoder" class="com.myProject.core.security.HmacPasswordEncoder" />

<authentication-manager id="clientAuthenticationManager" >
    <authentication-provider user-service-ref="myUserDetailsService">
        <password-encoder ref="encoder" />
    </authentication-provider>
</authentication-manager>

Any ideas why its complaining, when I have clearly defined my authentication-manager and authentication-provider?

Note: this might help, its a more descriptive error:

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 <authentication-manager> element to your configuration (with child
<authentication-provider> elements)? Alternatively you can use the authentication-manager-ref
attribute on your <http> and <global-method-security> elements.
Biju Kunjummen :

The authenticationManager is looked up by name, so just change it to the following:

<authentication-manager alias="authenticationManager">
    <authentication-provider user-service-ref="myUserDetailsService">
        <password-encoder ref="encoder" />
    </authentication-provider>
</authentication-manager>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring required a bean of type 'AuthenticationManager'

Error creating bean with name AuthenticationManager

@Named bean not injected into @Stateless bean

Field authenticationManager in service.SecurityServiceImpl required a bean of type 'org.springframework.security.authentication.AuthenticationManager'

No bean named is defined

No bean named xxx available

No bean named 'transactionManager' is defined

No bean named 'transactionManager' available

No bean named 'CustomAuthenticationProvider' is defined

No bean named 'myJobPerformable' available

No bean named 'transactionInterceptor' is defined

required a bean of type org.springframework.security.authentication.AuthenticationManager

Spring MVC AuthenticationManager expected single matching bean but found 4

Spring Boot APPLICATION FAILED TO START due to required a bean of type AuthenticationManager

@Named bean not found in JSF page

Error - No bean named 'springSecurityFilterChain' available

NoSuchBeanDefinitionException: No bean named 'authService' available

Spring set bean name with @Named

No Bean Named Available - XML Configuration

No bean named 'aboutus' available, NoSuchBeanDefinitionException

NoSuchBeanDefinitionException: No bean named 'name' is defined

NoSuchBeanDefinitionException: No bean named 'FirstPage' is defined

Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration

Spring-boot OAuth2 implementation: NoSuchBeanDefinitionException: No qualifying bean of type AuthenticationManager

Declaring AuthenticationManager Bean throws exception "Cannot apply DaoAuthenticationConfigurer to already built object"

Spring security custom filter (reason for creating AuthenticationManager bean while it already exists)

What is the default scope of a Named CDI bean?

@Asynchronous CDI Events and an @Observes method in @Named bean

No bean named 'springSecurityFilterChain' is defined Java Config