cancel
Showing results for 
Search instead for 
Did you mean: 

Deserialization - ClassCastException after datatype of a Custom class changed

bhola
Champ in-the-making
Champ in-the-making
Hi All,

Recently I changed the datatype of a variable in a custom class from Integer to Double.
When I start processing the older applications activiti is throwing classcastexception while assigning Integer to Double.

Could anybody can help me how to get rid of this problem in activiti based applications?

Can I modify the BLOB serializied object in ACT_GE_BYTEARRAY table in any way to set the changed datatype?
Or any other ways there to handle the deserializing process of activiti?

If anyone can help with bit details it would be much helpful.

Thanks
3 REPLIES 3

warper
Star Contributor
Star Contributor
Hi bhola!
It's not activiti specific (de)serialization, just java (de)serialization.

In general if you set serialverionUID, serialization survives addition/deletion of fields, but not  field type changes .
For this particular case  you can create new field instead of changing its type. Coverage with getter/setter can hide old field from outer classes… well, for JAXB and similar reflection-field-access tools you'll have to tweak annotations (make old field transient, make sure new field is initialized or accessed through getter/setter), but it's not activiti problem. Also you can derive new field value out of old field value if needed.


You can change blob serialized in ACT_GE_BYTEARRAY if you can find every occurence of your type variables in all history and running processes. You'll have to read blob, deserialize it into old class, transform it into new class and save blob. Probably you'll need different class loader for new class.

You can also derive custom (de)serialization methods for class, saving its version (or serialization options) and (de)serializing some fields differently for different versions. Unfortunately it's not generally compatible to streams that were created without custom serialization as version info should be saved into that same stream in addition to normal data.

bhola
Champ in-the-making
Champ in-the-making
Hi Warper,

Thanks for your quick suggestions and answers.
Could you please provide little more insight if there is anyway to customize activiti process of serializing and deserializing?

Regards,
Bhola

warper
Star Contributor
Star Contributor
Hi Bhola!
I don't think it's customizable in activiti code. As far as I remember, activiti calls ibatis that makes some things depending on underlying database, but in the end it calls standard serialization readObject/writeObject to create blob that goes through JDBC connection to database.
So you can customize your class serialization mechanics if needed.
http://www.oracle.com/technetwork/articles/java/javaserial-1536170.html
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.