试了下hessian的远程调用,网上例子很多,随便down了几个下来测试,结果都有异常:
2010-7-20 13:42:34 com.caucho.hessian.io.SerializerFactory getDeserializer警告: Hessian/Burlap: 'work' is an unknown class in sun.misc.Launcher$AppClassLoader@19821f:java.lang.ClassNotFoundException: workjava.lang.reflect.UndeclaredThrowableException at $Proxy0.getMap(Unknown Source) at hessian.TestHessian.main(TestHessian.java:21)Caused by: java.io.EOFException: readObject: unexpected end of file at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2054) at com.caucho.hessian.io.CollectionDeserializer.readLengthList(CollectionDeserializer.java:93) at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1995) at com.caucho.hessian.io.CollectionDeserializer.readLengthList(CollectionDeserializer.java:93) at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1995) at com.caucho.hessian.io.MapDeserializer.readMap(MapDeserializer.java:114) at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1592) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:253) ... 2 morejava.lang.reflect.UndeclaredThrowableException
Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianProtocolException: expected integer at 0x53 java.lang.String (com.luochao.hessian.dto.NoteBook) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:268) at $Proxy0.getNoteBook(Unknown Source) at com.luochao.hessian.test.TestHessian2.main(TestHessian2.java:15)Caused by: com.caucho.hessian.io.HessianProtocolException: expected integer at 0x53 java.lang.String (com.luochao.hessian.dto.NoteBook) at com.caucho.hessian.io.Hessian2Input.error(Hessian2Input.java:2765) at com.caucho.hessian.io.Hessian2Input.expect(Hessian2Input.java:2736) at com.caucho.hessian.io.Hessian2Input.readInt(Hessian2Input.java:796) at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1621) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:253) ... 2 more
只有返回String能正常,遇到Map,List,JavaBean等都出现异常,网上也没找到相关异常描述; 最后解决,resin3.1服务器自带了hessian.jar的包,和我使用的不一致导致了异常。 大家出现异常时也可以查看下hessian包是否有服务器端和客户端不一致,或者是服务器自带了不同版本的hessian.jar包