0

Firstly I was getting the Exception - `

java.io.InvalidClassException local class incompatible: stream classdesc serialVersionUID = 4597316331807173261, local class serialVersionUID = -3344057582987646196`,

as there is not a serialVersionUID in the class COOKIE of the API HtmlUnit that I am using, this exception occurs as the class Cookie is changed because we upgrade the version of HtmlUnit that we are using, so what idea comes to my mind is to avoid the matching of serialversionUID while deserialing, so I have tried the below solution ::

How to deserialize an object persisted in a db now when the object has different serialVersionUID

and Now it converts my streamUID to LocalUID but this exception comes to me

StreamCorruptedException: invalid type code: 00

Community
  • 1
  • 1
Girish
  • 1,677
  • 1
  • 17
  • 29
  • use default `serialVersionUID`. – Braj Apr 28 '14 at 18:36
  • @Braj, currently I m using the default one ........... my friend – Girish Apr 28 '14 at 18:41
  • What is default `serialVersionUID`? – Braj Apr 28 '14 at 18:41
  • @Braj, when we not declare serialVersionUID in the class implementing serializable interface then the default one is generate for the class .............. – Girish Apr 28 '14 at 18:44
  • use `private static final long serialVersionUID = 1L;` in each class. – Braj Apr 28 '14 at 18:45
  • @Braj, I know that this solves my problem but I have to avoid it , as this class is not the part of my code this is from HTMLUNIT api , so I can't change , some thing I have to done in my code – Girish Apr 28 '14 at 18:48
  • Why are you serializing HTMLUnit classes? This is the real problem. You shouldn't be serializing classes from a test framework. @Braj Your suggestion is incorrect. See the message. It should be 'serialVersionUID = 4597316331807173261'. – user207421 Apr 28 '14 at 18:50
  • @EJP, as Cookie is stored somewhere in the DB with BLOB message and then I deserialize the same to show this on GUI – Girish Apr 28 '14 at 18:54
  • But why? It's invalid. The test framework won't be there at deployment time surely? – user207421 Apr 28 '14 at 18:58
  • @EJP No my friend it surely there as we are working in the OSGI environment , so I have created the bundle for the HtmlUnit api, and that bundle is imported by my code bundle – Girish Apr 28 '14 at 19:00
  • @enthu-man I still see no reason to serialize a cookie object. HTTP cookie is really just a string, so why not save it to DB as such. – eis Apr 28 '14 at 19:14

0 Answers0