在开发中遇到这个bug,controller层通过dubbo进行调用服务,出现dubbo序列化的问题:expected map/object at java.lang.String
错误信息如下:
cause: org.apache.dubbo.remoting.RemotingException: Fail to decode request due to: com.alibaba.com.caucho.hessian.io.HessianProtocolException: expected map/object at java.lang.String (https://yyxx-yld.oss-cn-huhehaote.aliyuncs.com/yyxx-yld/yld-image/user_pic/owner_user/2021/02/02/4be9be73741b43c686c02bd141aec720.jpg)
com.alibaba.com.caucho.hessian.io.HessianProtocolException: expected map/object at java.lang.String (https://yyxx-yld.oss-cn-huhehaote.aliyuncs.com/yyxx-yld/yld-image/user_pic/owner_user/2021/02/02/4be9be73741b43c686c02bd141aec720.jpg)
at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.error(AbstractDeserializer.java:131)
at com.alibaba.com.caucho.hessian.io.AbstractMapDeserializer.readObject(AbstractMapDeserializer.java:70)
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2267)
at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2074)
at org.apache.dubbo.common.serialize.hessian2.Hessian2ObjectInput.readObject(Hessian2ObjectInput.java:92)
at org.apache.dubbo.common.serialize.ObjectInput.readAttachments(ObjectInput.java:87)
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:149)
at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:79)
at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:57)
at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:44)
at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
---
代码:
public Result auxiliaryInfoCommit(@RequestBody @Valid XwuxiliaryInfoReqVo xwuxiliaryInfoReqVo,HttpServletRequest request) {
String clientIP = HttpUtils.getClientIP(request);
GTuxiliaryInfoReqVo gTuxiliaryInfoReqVo = new GTuxiliaryInfoReqVo(xwuxiliaryInfoReqVo,clientIP);
return setResult(registService.auxiliaryInfoCommit(gTuxiliaryInfoReqVo, RegistTypeEnum.XW_TYPE_ENUM));
}
debug:
[图片上传失败...(image-f6e149-1612257606675)] 缺失照片了:显示该类的确存在,且属性齐全
网上有的说是dubbo版本 消费端与提供者版本不一致的问题,但是我们的是一致的
还有的说法是 由于传参的类 没有默认的空参构造。
最终经过尝试:真的是由于缺失空参构造引起的
网友评论