tiandike wrote:
I use ObjectSerializationCodecFactory in my mina client and server .
My client send a request to the server and server send response to client .
when I change my response dataobject in my client such as remove or add a
field in the response class ,this will lead the client error:

Caused by: java.lang.ClassCastException: cannot assign instance of
java.lang.String to field BaseUserDO.promotedDate1 of type java.util.Date in
instance of BaseUserDO
        at


MINA's ObjectSerializationCodecFactory uses classic Java serialization under the hood which means that you must have the same version of the class you serialize on both the client and the server. If you add/remove a field on the client the server must also be changed to get the same version of the class. I guess you could make this work by implementing custom (de)serialization for your classes. Please have a look at the javadoc for java.io.Serializable. It gives a nice summary of how serialization in Java works and how to override the default behaviour..

HTH

/Niklas

Reply via email to