ClassCastException serialization/deserialization
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajeev_Bacchu
Posted On:   Monday, May 3, 2004 02:10 AM

I have serialized MyBean on one system and it is transported as a file to another where it is deserialized using an ObjectInputStream. The Object that I get after reading the stream, I am not able to typecast it to MyBean. It throws a ClassCastException and if(obj instanceof MyBean) gives me false. but System.out.println(obj); Shows me the correct MyBean type I am not able to figure out why. Can I get some help please? I have made sure: Th class files on the system where the object is saved and the class files on the system where it is read are same.    More>>

I have serialized MyBean on one system and it is transported as a file to another where it is deserialized using an ObjectInputStream. The Object that I get after reading the stream, I am not able to typecast it to MyBean.


It throws a ClassCastException and


if(obj instanceof MyBean) gives me false.


but System.out.println(obj); Shows me the correct MyBean type


I am not able to figure out why. Can I get some help please?


I have made sure:
Th class files on the system where the object is saved and the class files on the system where it is read are same.

   <<Less

Re: ClassCastException serialization/deserialization

Posted By:   Sean_Owen  
Posted On:   Thursday, May 6, 2004 11:59 AM

It sounds like this should work. Post your exact code to see if somebody can spot a problem.

Re: ClassCastException serialization/deserialization

Posted By:   Sean_Owen  
Posted On:   Thursday, May 6, 2004 11:59 AM

It sounds like this should work. Post your exact code to see if somebody can spot a problem.
About | Sitemap | Contact