首页 > 解决方案 > Springboot Oauth2:org.springframework.security.oauth2.provider.error.DefaultWebResponseExceptionTranslator$UnauthorizedException

问题描述

我正在尝试实现一个功能齐全的 Spring-boot oauth2。我设法使用成功凭据实现登录,我使用 access_token 和 refresh_token 得到正确的响应,使用/oauth/token

使用正确的用户名和密码

{
"access_token": "b8c45984-c573-4837-9ef6-6896f308a286",
"token_type": "bearer",
"refresh_token": "48145463-830e-4467-ab89-587bda6b32de",
"expires_in": 43199,
"scope": "read write"

}

如果我使用了错误的用户名,它会给我一个正确的错误,我很高兴;

错误的用户名:

{error: "unauthorized", error_description: "No value present"}

错误:“未经授权” error_description:“没有值存在”

但是当我使用正确的用户名和错误的密码时问题就来了;我收到以下错误

2018-05-28 14:47:25.264  WARN 6604 --- [nio-8088-exec-2] .c.j.MappingJackson2HttpMessageConverter : 
Failed to evaluate Jackson serialization for type [class     org.springframework.security.oauth2.provider.error.DefaultWebResponseExceptionTranslator$UnauthorizedException]:
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name     'org.springframework.security.oauth2.common.exceptions.OAuth2ExceptionJackson2Serializer': 
 BeanPostProcessor before instantiation of bean failed; 
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource
 [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: 
 Bean instantiation via factory method failed; 
 nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate      [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: 
 Factory method 'transactionAdvisor' threw exception; 
 nested exception is java.lang.NullPointerException

标签: spring-bootspring-securityjacksonspring-security-oauth2

解决方案


推荐阅读