This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have an application which was running on JBoss4 and had some data serialized ( saved in database ).
Now, we migrated the application to JBoss6 with the serialized data retained. However, when reading one of the entities from this data, I am facing InvalidClassException.
The exception is similar to
I understand that this error can occur in case of serializing entities with a class and trying to deserialize it back with the same class(but with different serialversion uuid). The entity that I am trying to read has compatible changes. So, I believe there should not be any issue with my entity.
And, the exception also does not complain about my entity but rather complaining about the Hibernate class SerializableProxy being different.
Any ideas on what is wrong here and how I can resolve this?
I'll take a guess at this. Because you used Hibernate to store your data in the database, most likely your object was serialized as part of the SerializableProxy object. And now, because there is a more recent version of Hibernate in AS 6 than there was in 4 (which version of 4, they are all very different), you won't be able to access the object unless you run with the older version of Hibernate. This might involve packaging the older Hibernate JARS with your app and configuring a classloader repository. Then there is the issue with regard to how to update the database; for that I have no definitive answer (I can think of some ways, they are all ugly, and I have no idea if Hibernate provides a migration tool for such things).
Thanks for the response.
Even I was suspecting the issue is because of hibernate version change between JBoss6 and 4. But it is surprising to me as to how this backward compatibility can break as I believe there would be lots of people who would be migrating their applications(with data saved) to use newer versions of Hibernate or JBoss as such. May be I need to check in Hibernate forums as well..