During scenario including client-server communication Exception is thrown during deserialization.
Scenario, which includes client-server communication, fails with Exception during deserialization of received object:
- Caused by: java.io.InvalidClassException
When a class is declared as Serializable and could be serialized and deserialized via network, it has it own SerialVersionUID. It is a number of type "long", which determinates the class version in Java Virtual Machine where the class was serialized and class version in Java Virtual Machine where the class is deserialized are one and the same.
If SerialVersionUID is not specified, it is generated one by default during serialization. The SerialVersionUID depends on Java version, methods, and fields in the class.
Here we have an example of SerialVersionUID in a Serializable class:
* Determines if a de-serialized file is compatible with this class.
* Maintainers must change this value if and only if the new version
* of this class is not compatible with old versions. See Sun docs
* for <a href = "http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc.html"> details. </a>
private static final long serialVersionUID = 7526471155622776147L;
Here are some forums where the topic is discussed:
Contact the responsible for the incompatible class component to state which the incompatibility is or fix the serialVersionUID. The responsible developer should provide the fix for the incompatibility or official documentation, why these versions are incompatible by design.
Incompatibility may be caused by changing Java Version in the other side if serialVersionUID is not declared in class, nevertheless most of Java Code editors reminds to developer to generate SerialVersionUID.
The responsible developer should make the new version of the class to be with the same version of serialVersionUID as the old one and downport the fix to affected incompatible versions unless the incompatibility in classes is made on purpose and is documented.
Incompatibility could be removed with:
- Generation of serialVersionUID in the class, which must match to the value in older version;
- If automatic generation does not match - manually correct the serialVersionUID
- To use one and the same version of the class in both sides of client-server communication.
The problem may be caused by using:
Client 7.20 connecting to server version 7.10; or
Client 7.00 connection to server version 7.11;
If the class was changed to have generated serialVersionUID = 1, this incompatibility must be fixed to automatically generated serialVersionUID during serialization of the class in the previous version of the class.
Related SAP Notes