hessian 常见问题
hessian接口服务端和客户端对象不一致问题
字段数量不一致
hessian允许客户端和服务端对象字段不一致,增加、删除字段都不影响,但是对于同名字段,必须保证字段类型一致,否则会报异常:
- 例如服务端为BigDecimal,客户端为int:
1
com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianFieldException: com.demo.entity.DemoBean.number: expected integer at 0x43 java.math.BigDecimal (1233456)
接口返回值类型不一致
当服务端返回对象和客户端期望获取的对象不一致时,比如服务端返回类型为A,但是客户端接受的返回类型为B,此时hessian使用map映射的方式解析,根据字段名映射,但是会记录一些警告日志:
1
2
3
4
5
6
7
8[2017-06-15 22:17:00,267] 警告 com.caucho.hessian.io.SerializerFactory getDeserializer - Hessian/Burlap: 'com.demo.entity.DemoBean' is an unknown class in sun.misc.Launcher$AppClassLoader@18b4aac2:
java.lang.ClassNotFoundException: com.demo.entity.DemoBean
[2017-06-15 22:17:00,282] 较详细 com.caucho.hessian.io.SerializerFactory getDeserializer - java.lang.ClassNotFoundException: com.demo.entity.DemoBean
[2017-06-15 22:17:01,194] 警告 com.caucho.hessian.io.SerializerFactory getDeserializer - Hessian/Burlap: 'com.demo.entity.DemoBean' is an unknown class in sun.misc.Launcher$AppClassLoader@18b4aac2:
java.lang.ClassNotFoundException: com.demo.entity.DemoBean
[2017-06-15 22:17:01,194] 较详细 com.caucho.hessian.io.SerializerFactory getDeserializer - java.lang.ClassNotFoundException: com.demo.entity.DemoBean
MyHessianServlet.getDeserializer: com.demo.entity.Demo2Bean
[2017-06-15 22:17:01,196] 详细 com.caucho.hessian.io.SerializerFactory getObjectDeserializer - hessian: expected deserializer 'com.demo.entity.Demo2Bean' at 'com.demo.entity.DemoBean' (java.util.HashMap)