I have a problem with my first steps in Serialization / Deserialization.
Scenarion 1: - Create a HashSet - fill it with Integer objects - serialize it to file -> ok. - deserialize it from file - read HashMap -> ok.
Scenarion 2, almost the same code - Create a HashSet, - fill it with trivial objects ("SerObject", only one String member) - serialize it to file - deserialize it from file -> ClassNotFoundException SerObject.
can someone please point me in the right direction?
This sounds like a common misconception about what serialization does: the SerObject class file has to be available on the classpath of the program that deserializes the file. The class definition isn't serialized, only the objects themselves.
How did you put the SerObject's class definition into the deserialization client's package? Did you change the "package" declaration in SerObject.java on the client side? In that case, you have two different classes: serializer.SerObject and deserializer.SerObject. Or did you copy the class file for serializer.SerObject into the package dir for deserializer? In that case, it should be in a "serializer" directory instead to match its package hierarchy.
If it's neither of those, it's something more insidious.
Consultant to SCJP team.<br />Co-designer of SCJD exam.<br />Co-author of "Complete Java 2 Certification Study Guide".<br />Author of "Ground-Up Java".
Joined: Feb 03, 2004
Phillip, you were 100% right... I took the class definition over to the client, but put it into the wrong package.... STupid me.
Thx a lot for helping, Jan
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Problem with Serialization / Deserialization