在開發(fā)中遇到這個bug,controller層通過dubbo進行調用服務,出現(xiàn)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版本 消費端與提供者版本不一致的問題,但是我們的是一致的
還有的說法是 由于傳參的類 沒有默認的空參構造。
最終經過嘗試:真的是由于缺失空參構造引起的