项目场景:
A服务rpc调用B服务service报错
问题描述:
记录一次post请求遇到的坑
@PostMapping(value = "/getSkDetailList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public BaseResponse<PageInfo<ActivitySkDetailDTO>> getSkDetailList(@RequestBody ActivitySkDetailReq req) {
return activitySkDetailService.getSkDetailList(req);
}
报错信息:
"code": "500",
"message": "JSON parse error: Can not construct instance of java.util.ArrayList: no String-argument constructor/factory method to deserialize from String value (''); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.util.ArrayList: no String-argument constructor/factory method to deserialize from String value ('')\n at [Source: java.io.PushbackInputStream@19d2d13; line: 1, column: 23] (through reference chain: com.longfor.gaia.gfs.core.response.BaseResponse[\"data\"])",
解决方案:
rpc调用另一个服务的service中的接口,因为另一个服务里面有拦截器,所以导致这个错误。让人难受的是拦截器拦截后抛的错是反序列化的错,所以导致一直定位不到错误的地方,以此记录一下这个错。