Deserialization - ClassCastException after datatype of a Custom class changed

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 05:56 AM
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
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
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 10:40 AM
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.
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.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 02:55 AM
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
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 09:40 AM
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
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
