You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
我们使用dubbo的时候,返回的结果对象是这样的
class Result {
int code;//错误码
String message;//错误消息
T module ;//保存数据
}
但是调用时报反序列失败,报错如下: Exception in thread "main" com.alibaba.com.caucho.hessian.io.HessianFieldException: AVX$Result.data: com.alibaba.com.caucho.hessian.io.ObjectDeserializer: unexpected object java.lang.String (2) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:163) at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:394) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:269) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:196) at com.alibaba.com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:527) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2743) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2683) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2657) at AVX.deserialize(AVX.java:37) at AVX.main(AVX.java:18) Caused by: com.alibaba.com.caucho.hessian.io.HessianProtocolException: com.alibaba.com.caucho.hessian.io.ObjectDeserializer: unexpected object java.lang.String (2) at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.error(AbstractDeserializer.java:101) at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.readMap(AbstractDeserializer.java:90) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2066) at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:390) ... 8 more
我们使用dubbo的时候,返回的结果对象是这样的
class Result {
int code;//错误码
String message;//错误消息
T module ;//保存数据
}
但是调用时报反序列失败,报错如下:
Exception in thread "main" com.alibaba.com.caucho.hessian.io.HessianFieldException: AVX$Result.data: com.alibaba.com.caucho.hessian.io.ObjectDeserializer: unexpected object java.lang.String (2) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:163) at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:394) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:269) at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:196) at com.alibaba.com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:527) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2743) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2683) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2657) at AVX.deserialize(AVX.java:37) at AVX.main(AVX.java:18) Caused by: com.alibaba.com.caucho.hessian.io.HessianProtocolException: com.alibaba.com.caucho.hessian.io.ObjectDeserializer: unexpected object java.lang.String (2) at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.error(AbstractDeserializer.java:101) at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.readMap(AbstractDeserializer.java:90) at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2066) at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:390) ... 8 more
代码如下:
`
import com.alibaba.com.caucho.hessian.io.Hessian2Input;
import com.alibaba.com.caucho.hessian.io.Hessian2Output;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
public class AVX {
public static void main(String[] args) throws IOException, ClassNotFoundException {
HashMap<String, String> map = new HashMap<>();
map.put("2", "2");
}`
经过测试,如果
static class Result<T extends Serializable> implements Serializable {
改为
static class Result<T> implements Serializable {
则能正常反序列化出来。
求大神帮助 看看
The text was updated successfully, but these errors were encountered: