As stated in the documentation, this can happen for three reasons:
- The serial version of the class does not match the description of the class descriptor read from the stream
- The class contains unknown data types.
- The class has no no-arg constructor available.
So, first of all, make sure that both implementations have the same serialVersionUID . If this is true, you must be sure that the class does not use any type of undefined (or unknown) for the JVM to which you are trying to deserialize. Finally, you need to provide the standard constructor ClassName() , which performs empty initialization.
These can be problems and, of course, one of them, so I donβt think you should expect something strange. From my personal experience, I can also add that using different versions of the JVM for serialization and deserialization can create this problem, so be sure to verify this.
source share