Thursday, October 6, 2011

Coherence: POF Exceptions

If you are trying to use POF for object serialization as recommended for better performance and less RAM utilization with Coherence, there are 2 ways to implement it:

1. Implement PortableObject interface for all objects that will be stored in the Coherence Grid - Need to modify the object class and implement readExternal and writeExternal methods.
2. Externalize the serialization logic by creating classes that implement PofSerializer interface and logic for serialization and de-serialization of your objects is implemented in this class using the serialize/deserialize methods. Later, you can map this class as the serializer for your object in pof-config.xml

More details on both the above ways can be found here.

If you are getting an error while using the PortableObject interface as below:

Caused by: java.io.EOFException: user type POF stream terminated at com.tangosol.io.pof.PofBufferWriter$UserTypeWriter.writeUserTypeInfo(PofBufferWriter.java:2621) at com.tangosol.io.pof.PofBufferWriter$UserTypeWriter.writeRemainder(PofBufferWriter.java:2497) at com.tangosol.io.pof.PortableObjectSerializer.serialize(PortableObjectSerializer.java:96) at com.tangosol.io.pof.PofBufferWriter.writeUserType(PofBufferWriter.java:1667)
... 13 more


Remember to remove the readRemainder() and writeRemainder() from the readExternal/writeExternal methods as they are used with POFSerializer interface.

No comments:

Search This Blog