When deserializing a serialized tree of objects, the classes of all objects must be in the class path. In this context, a ClassNotFoundException most likely means that one of the classes that is not required is not in the classpath. You must solve this problem for deserialization.
In this case, es4.Automobile missing.
Could the problem be caused by a special exception that I made that was launched by Automobile?
The only other possibilities that I can think of are as follows:
es4.Automobile is directly or indirectly dependent on some other class that is missing- static initialization of
es4.Automobile or a dependent class raised an exception that was not detected inside the class.
But both of them should (I think) lead to a different stack trace.
I just noticed that the package name is es4p2, not es4. Why does it say es4? Maybe because the program that saves the file uses a different package name?
I have no idea why they are different. You will need to talk to the person who wrote the code / created the serialized objects. However, this is most likely the cause of your problem. A class with a different package name is a different class. Period.
You should always pop up (or, better, register) the stack when an unexpected exception occurs. This will tell you (and us) more about what went wrong, in which case the class name is missing.
source share