1

I am using 1.0.0.RELEASE version of spring-security-oauth2. My Maven dependency is :

<dependency>
    <groupId>org.springframework.security.oauth</groupId>
    <artifactId>spring-security-oauth2</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

This is the bean definition I have in my application context.

<bean id="inMemoryTokenStore"
    class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore">
</bean>

<bean id="tokenServices"
    class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
    <property name="tokenStore" ref="inMemoryTokenStore" />
</bean>

<bean id="oAuth2AuthenticationManager"
    class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager">
    <property name="tokenServices" ref="tokenServices" />
</bean>

<bean id="oAuth2AuthProcessingFilter"
    class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter">
    <property name="authenticationManager" ref="oAuth2AuthenticationManager" />
    <qualifier value="oAuth2"/>
</bean>

When I try to create bean, I get the following weird exception with no specific information.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oAuth2AuthProcessingFilter' defined in class path resource [com/etrade/spring/security/oauth/web/application/OAuth2Filters-context.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
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.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
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)
... 28 more
Caused by: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:76)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:282)
at org.springframework.core.GenericTypeResolver.getTargetType(GenericTypeResolver.java:65)
at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:80)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodParameter(GenericTypeAwarePropertyDescriptor.java:150)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.isExcludedFromDependencyCheck(AbstractAutowireCapableBeanFactory.java:1269)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1101)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 41 more

I read similar issues on Stackoverflow and tried suggestions like verifying that there is no spring version conflict but nothing helped. Please let me know how this could be fixed.

4

1 回答 1

0

我想我会对这个问题有所了解,因为我也在研究这个问题。

如果我们查看OAuth2AuthenticationProcessingFilter.java,它将类型设置为authenticationDetailsSourceas AuthenticationDetailsSource<HttpServletRequest, ?>,但直到至少版本 3.1.0.M1 才被模板化(参见SEC-1486github 上的源代码)。

简而言之,spring-security-oauth需要3.1.x 的 spring security 才能工作。在我们升级它之前,我将尝试一个混乱的解决方法,因为我们依赖一个需要 3.0.x 的 grails 插件。

于 2013-11-21T01:42:50.930 回答