Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TokenServicesUserApprovalHandler not found in latest spring-security-oauth2-2.0.6.RELEASE.jar

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler">
  <property name="tokenServices" ref="tokenServices" />
</bean>

The following code in my spring-security.xml was working with spring-security-oauth2-1.0.1.RELEASE.jar but when I upgraded it to spring-security-oauth2-2.0.6.RELEASE.jar the above file ie, "org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler" was not found.

I was doing this because with previous jar there was some conflict regarding jackson due to Spring 4.1.X

17:14:53,679 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.oauth2.provider.token.DefaultTokenServices
com.aricent.ans.controller.um.UserController.tokenServices; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenServices' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Cannot
resolve reference to bean 'clientDetails' while setting bean property 'clientDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDetails' defined in ServletContext resource
[/WEB-INF/spring-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.oauth2.provider.JdbcClientDetailsService]: Constructor
threw exception; nested exception is java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
like image 984
harshlal028 Avatar asked Feb 26 '15 04:02

harshlal028


1 Answers

It was a change with the version of Spring OAuth2 you're using. Try this:

<bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler">
    <property name="tokenStore" ref="tokenStore"/>
</bean>
like image 122
jgladch Avatar answered Oct 26 '22 23:10

jgladch