TokenServicesUserApprovalHandler not found in recent 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 worked with spring -security-oauth2-1.0.1.RELEASE.jar, but when I updated it to spring -security-oauth2-2.0.6.RELEASE.jar, the above file, t .e. "org.springframework.security.oauth2.provider.approval.TokenServicesUserApprovalHandler" not found.

I did this because with the previous jar there was a conflict between Jackson over 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 
+5
source share
1 answer

This was a change with the spring version of OAuth2 that you are using. Try the following:

 <bean id="userApprovalHandler" class="org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler"> <property name="tokenStore" ref="tokenStore"/> </bean> 
+6
source

Source: https://habr.com/ru/post/1214211/


All Articles