If i use mina ObjectSerializationCodecFactory  ,and want to support
versioning , do I need to provide void writeObject(ObjectOutputStream s) and
readObject(ObjectInputStream s) function in my dataobject? 




Niklas Therning wrote:
> 
> 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
> 
> 
> 
> -----
> Niklas Therning
> www.spamdrain.net
> 

-- 
View this message in context: 
http://www.nabble.com/a-question-about-mina-Serialization-tp15079319s16868p15085494.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to