PDA

View Full Version : Can Hessian de/serialize java object that implements Externalizable interface?


thynamite
01-18-2012, 07:25 PM
I love the performance and footprint of Hessian. I am trying to de/serialize java object that contains fields (Trove collections) which implements java Externalizable interface. I am not able to google any useful documentation whether Hessian will support this. In my case, I just want to save the java object onto disk and able to retrieve it later. Thanks in advance on any help on this topic.

Here is the stacktrace I got:

java.lang.RuntimeException: Serialized class gnu.trove.map.hash.TIntObjectHashMap$1 must implement java.io.Serializable
field: gnu.trove.map.hash.TIntObjectHashMap.PUT_ALL_PROC
class: gnu.trove.map.hash.TIntObjectHashMap (object={1=0.0})
field: com.trg.data.Fund.mapRiskSettingRiskMeasure
class: com.trg.data.Fund (object=TRGGOMF-1)
at com.caucho.hessian.io.UnsafeSerializer.writeInstan ce(UnsafeSerializer.java:215)
at com.caucho.hessian.io.UnsafeSerializer.writeObject (UnsafeSerializer.java:171)
at com.caucho.hessian.io.Hessian2Output.writeObject(H essian2Output.java:421)
at com.trg.cache.TRGHessianFileCacheManagerImpl.write Data(TRGHessianFileCacheManagerImpl.java:58)
...

Caused by: java.lang.RuntimeException: Serialized class gnu.trove.map.hash.TIntObjectHashMap$1 must implement java.io.Serializable
field: gnu.trove.map.hash.TIntObjectHashMap.PUT_ALL_PROC
class: gnu.trove.map.hash.TIntObjectHashMap (object={1=0.0})
field: com.trg.data.Fund.mapRiskSettingRiskMeasure
at com.caucho.hessian.io.UnsafeSerializer$ObjectField Serializer.serialize(UnsafeSerializer.java:295)
at com.caucho.hessian.io.UnsafeSerializer.writeInstan ce(UnsafeSerializer.java:212)
... 24 more
Caused by: java.lang.RuntimeException: Serialized class gnu.trove.map.hash.TIntObjectHashMap$1 must implement java.io.Serializable
field: gnu.trove.map.hash.TIntObjectHashMap.PUT_ALL_PROC
class: gnu.trove.map.hash.TIntObjectHashMap (object={1=0.0})
at com.caucho.hessian.io.UnsafeSerializer.writeInstan ce(UnsafeSerializer.java:215)
at com.caucho.hessian.io.UnsafeSerializer.writeObject (UnsafeSerializer.java:171)
at com.caucho.hessian.io.Hessian2Output.writeObject(H essian2Output.java:421)
at com.caucho.hessian.io.UnsafeSerializer$ObjectField Serializer.serialize(UnsafeSerializer.java:293)
... 25 more

ferg
01-30-2012, 07:25 PM
No, because Externalizable is specific to Java serialization; it takes control of the
output stream.

In Hessian, if you want to create a proxy or other format, you can use writeReplace() and readResolve() to convert to the class that you'd like on the wire.