I am facing error in configuring the Ouath2.Its giving BeanCreationException.
Below is the stacktrace,please help me out in solving this.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDetails': Cannot create inner bean '(inner bean)' of type [org.springframework.security.oauth2.provider.client.BaseClientDetails] while setting bean property 'clientDetailsStore' with key [the_client]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'autoApproveScopes' of bean class [org.springframework.security.oauth2.provider.client.BaseClientDetails]: Bean property 'autoApproveScopes' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:126) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:379) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:162) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
... 98 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'autoApproveScopes' of bean class [org.springframework.security.oauth2.provider.client.BaseClientDetails]: Bean property 'autoApproveScopes' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1423) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
... 110 more
**Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'autoApproveScopes' of bean class [org.springframework.security.oauth2.provider.client.BaseClientDetails]: Bean property 'autoApproveScopes' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?**
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1042) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:902) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1420) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
... 114 more
Related
I want to add spring social facebook (spring social 1.1.4 and spring social facebook 1.1.1) with spring security 4.0.3 using XML configuration,
I'm unable to add SocialAuthenticationFilter :
<b:bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter">
<b:constructor-arg index="0" ref="authenticationManager" />
<b:constructor-arg index="1" ref="userIdSource" />
<b:constructor-arg index="2" ref="usersConnectionRepository" />
<b:constructor-arg index="3" ref="socialAuthenticationServiceLocator" />
</b:bean>
the execution fails due to this error message :
GRAVE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#1' while setting bean property 'sourceList' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'socialAuthenticationFilter' while setting constructor argument with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'socialAuthenticationFilter' defined in ServletContext resource [/WEB-INF/spring/security-context.xml]: Cannot resolve reference to bean 'socialAuthenticationServiceLocator' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'socialAuthenticationServiceLocator' is defined
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)
You need a proper socialAuthenticationServiceLocator defined in your context.
<bean id="socialAuthenticationServiceLocator" class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
<property name="authenticationServices">
<list>
<bean class="org.springframework.social.twitter.security.TwitterAuthenticationService">
<constructor-arg value="${twitter.apiKey}" />
<constructor-arg value="${twitter.appSecret}" />
</bean>
</list>
</property>
</bean>
In my project I'm using Spring 3 with Neo4j 2.0.1, I was using the embedded mode and everything was working fine.
In my code I use the Neo4jTemplate (#Autowired in my services) as well as the GraphRepository and RelationshipOperationsRepository.
I wanted to migrate my coode to use the standalone mode. Here's what I did :
In spring-context.xml, I made it like this :
<!-- Neo4J -->
<!-- neo4j:config storeDirectory="${neo.storeDir}" base-package="net.nextep.nextenergy.domain.graph" /-->
<bean id="graphDatabase" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data/" index="0"/>
</bean>
<neo4j:repositories base-package="net.nextep.nextenergy.repository.graph" />
I tried to run it, I got this error :
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'neo4jTemplate' is defined
I tried then to remove the #Autowired Neo4jTemplate from my services, use #Autowired private SpringRestGraphDatabase graphDB and create a new Template this way private Neo4jTemplate template = new Neo4jTemplate((GraphDatabase) graphDB)
And I still get the same error :
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userNodeRepository': Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'neo4jTemplate' is defined
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'neo4jTemplate' is defined
...
The UserNodeRepository :
#Repository
public interface UserNodeRepository extends GraphRepository<UserNode>,
RelationshipOperationsRepository<UserNode>{
public UserNode findById(String id);
public Node findNodeById(String id);
#Query("match (u:UserNode)-[:HABILITATED]->(f:Folder) where ID(u) = {0} return f")
public Set<Folder> getAllowedFoldersFirstLevel(UserNode user);
}
Am I doing wrong?
Name your bean "graphDatabaseService" and pass it to the config which you didn't create:
<neo4j:config graphDatabaseService="graphDatabaseService" base-package="net.nextep.nextenergy.domain.graph" />
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://localhost:7474/db/data/" index="0"/>
</bean>
<neo4j:repositories base-package="net.nextep.nextenergy.repository.graph" />
How can one set the connection pool size for a DBCP datasource? Also, is the default datasource pooled?
I tried to set maxTotal (http://commons.apache.org/proper/commons-dbcp/configuration.html), but it returns an invalid property error.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.driver}"/>
<property name="url" value="${db.url}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
<property name="poolPreparedStatements" value="false"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="true"/>
<property name="validationQuery" value="SELECT 1 FROM DUAL"/>
<property name="timeBetweenEvictionRunsMillis" value="30000"/>
<property name="maxTotal" value="1"/>
</bean>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class pat
h resource [META-INF/spring/base-gateway.xml]: Error setting property values; nested exception is org.springframework.be
ans.NotWritablePropertyException: Invalid property 'maxTotal' of bean class [org.apache.commons.dbcp.BasicDataSource]: B
ean property 'maxTotal' is not writable or has an invalid setter method. Does the parameter type of the setter match the
return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCap
ableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBea
nFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBea
nFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanF
actory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.jav
a:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFac
tory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationCo
ntext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at sf.av.core.gateway.GenericGateway.main(GenericGateway.java:23)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxTotal' of bean class [org.apache
.commons.dbcp.BasicDataSource]: Bean property 'maxTotal' is not writable or has an invalid setter method. Does the param
eter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1024)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCap
ableBeanFactory.java:1358)
... 13 more
You most likely have a mismatch between the version of the DBCP jar you are using and the configuration documentation, for example:
Users should also be aware that some configuration options (e.g. maxActive to maxTotal) have been renamed to align them with the new names used by Commons Pool 2.
Does the BasicDataSource class from the jar you are using have the maxTotal setter on it or not?
In reference to this question ("Server returned HTTP response code: 400 using Spring-Security AuthenticationProvider"), I've decided that I'm doing this all wrong. I'm trying to use a RESTful service to provide authentication that sends UsernamePasswordAuthenticationTokens back and forth, when I should be using a RemoteAuthenticationManager. (P.S. I'm ready to switch to basic auth, because this has been such a hassle. Unfortunately, that's not an option.)
So, I restructured.
Unfortunately, there is a dearth of examples of RemoteAuthenticationManagers.
I now have these beans in the server:
<bean id="remoteAuthenticationManager" class="org.springframework.security.authentication.rcp.RemoteAuthenticationManagerImpl">
<property name="authenticationManager">
<ref bean="phsAuthenticationManager"/>
</property>
</bean>
<bean id="phsAuthenticationManager" class="com.mystuff.phs.agent.service.AuthenticationManager">
<property name="endpoint" value="${phs.authenticate.endpoint}" />
</bean>
The AuthenticationManager code is here:
#Service("phsAuthenticationManager")
#Transactional
public class AuthenticationManager implements RemoteAuthenticationManager {
private String endpoint;
/** authenticate call to PHS authenticate service. */
#Override
public Collection<? extends GrantedAuthority> attemptAuthentication(String userName, String password) {
... // implementation details not important.
}
public String getEndpoint() {
return this.endpoint;
}
public void setEndpoint(String endp) {
this.endpoint = endp;
}
}
So, I'm getting the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [phs-datasource.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy48 implementing org.springframework.security.authentication.rcp.RemoteAuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy48 implementing org.springframework.security.authentication.rcp.RemoteAuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
Maybe my brain is fried from a week of trying to configure what seems to be a pretty straightforward interface. Please help?
Editing for slight change to project files:
A coworker made some changes to the app-security.xml file and I've integrated the changes suggested here. Here is the app-security.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true" pattern="/rest/**" entry-point-ref="http403EntryPoint"
authentication-manager-ref="remoteAuthenticationManager">
<intercept-url pattern="/rest/**" access="isAuthenticated()" />
<custom-filter ref="tenantHmacFilter" position="PRE_AUTH_FILTER" />
</http>
<beans:bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint">
</beans:bean>
<beans:bean id="tenantHmacFilter" class="com.mckesson.phs.agent.filter.TenantHmacFilter">
<beans:property name="authenticationManager" ref="tenantHmacAuthenticationManager" />
</beans:bean>
<beans:bean id="tenantHmacAuthenticationManager" class="com.mckesson.phs.agent.filter.TenantHmacAuthenticationManager">
<beans:property name="tenantId" value="${tenant.id}" />
<beans:property name="tenantKey" value="${tenant.key}" />
</beans:bean>
<beans:bean id="remoteAuthenticationManager" class="org.springframework.security.authentication.rcp.RemoteAuthenticationManagerImpl">
<beans:property name="authenticationManager">
<beans:ref local="authenticationManager" />
</beans:property>
</beans:bean>
<beans:bean id="authenticationManager" class="com.mckesson.phs.agent.service.AuthenticationManagerImpl">
<beans:property name="endpoint" value="${phs.authenticate.endpoint}" />
</beans:bean>
</beans:beans>
Here is the complete trace stack:
Wed 12:43:04.171 ERROR org.springframework.test.context.TestContextManager: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#15c44d6] to prepare test instance [com.mckesson.phs.agent.dao.AppointmentDaoImplTest#ab436d]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: 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 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [7]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#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 'remoteAuthenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [app-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' while setting constructor argument with key [7]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#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 'remoteAuthenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [app-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 49 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#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 'remoteAuthenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [app-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 63 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'remoteAuthenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [app-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 73 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteAuthenticationManager' defined in class path resource [app-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 85 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.security.authentication.AuthenticationManager' for property 'authenticationManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 91 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy47 implementing com.mckesson.phs.agent.service.AuthenticationManager,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.security.authentication.AuthenticationManager] for property 'authenticationManager': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 97 more
The error that you are getting is because of type mismatch. The Spring Security authenticationManager is configured like this:
<security:authentication-manager alias="authenticationManager" erase-credentials="true">
...
</security:authentication-manager>
This is then wired to RemoteAuthenticationManagerImpl:
<bean id="remoteAuthenticationManager" class="org.springframework.security.authentication.rcp.RemoteAuthenticationManagerImpl">
<property name="authenticationManager"><ref local="authenticationManager" /></property>
</bean>
If you are looking for HttpInvoker solution (both ends Spring) then above is configured like this:
<bean name="/RemoteAuthenticationManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service"><ref local="remoteAuthenticationManager"/></property>
<property name="serviceInterface" value="org.springframework.security.authentication.rcp.RemoteAuthenticationManager" />
</bean>
Please add more details on what you are trying to do. Are you implementing Spring Security in a distributed application something like Spring Security in a distributed application or Spring HTTP Invoker Authentication Questions?
I'm using Spring 3.1 and I am doing LDAP for the first time.
Here is my *-security.xml:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true">
<intercept-url pattern="/welcome*" access="ROLE_USER" />
<form-login login-page="/login" default-target-url="/welcome"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/logout" />
</http>
<ldap-server url = "ldap://ldap-east.abc.acme.org:636/o=acme.org" />
<authentication-manager>
<ldap-authentication-provider user-dn-pattern="uid={0},ou=people"/>
</authentication-manager>
</beans:beans>
I started with these security related jars in my lib:
spring-security-ldap-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
And I got this error message:
org.springframework.context.ApplicationContextException:
Couldn't locate: org.springframework.ldap.core.support.BaseLdapPathContextSource.
If you are using LDAP with Spring Security,
please ensure that you include the spring-ldap jar file in your application;
nested exception is java.lang.ClassNotFoundException:
org.springframework.ldap.core.support.BaseLdapPathContextSource
So, I added more jars to lib to be this set of security files:
spring-ldap-core-1.3.1.RELEASE.jar
spring-ldap-core-tiger-1.3.1.RELEASE.jar
spring-security-ldap-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
That got me in deeper with even MORE error messages:
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 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0'
while setting constructor argument with key [2];
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' w
hile 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.BeanCreationException:
Error creating bean with name 'org.springframework.security.authenticationManager':
Cannot resolve reference to bean 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0'
while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0':
Cannot create inner bean '(inner bean)' of type [org.springframework.security.ldap.authentication.BindAuthenticator]
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#17': Cannot resolve reference to bean 'org.springframework.security.securityContextSource'
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.security.securityContextSource':
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:
Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]:
Constructor threw exception; nested exception is java.lang.NoClassDefFoundE
I'm catching up on a lot of things, learning Maven is on my list, but I am not there yet. Any tips on getting the right mix jars to do a basic LDAP authentication with Spring 3.1?
I tried loading the entire Spring 3.1.1 dist, the entire Spring LDAP 1.3.1 dist and the entire Spring Security 3.1.0 dist. I've got everything. So I am at a loss to see how this is a dependency issue, FWIW.
spring-security-config
spring-security-taglibs
spring-security-ldap
Those 3 should be enough and they will pull their dependendies if you are using maven or similar tool.
If not, you need to go through all 3 libs and copy all their dependencies as well in your classpath.
Check this thread Moved to Spring 3.1.1 from Spring 3.0.5 now my App does not work
As ryan-stewart states:
Blockquote spring-ldap isn't included with the base spring 3.1 distro. In fact, its versioning is completely separate, and it's presently at version 1.3.1.
You need to download the extra jars from here
All the credit goes to ryan-stewart