Problem
During scenario including client-server communication Exception is thrown during deserialization.
Scenario fails.
Symptom
Scenario, which includes client-server communication, fails with Exception during deserialization of received object:
Example traces:
Caused by: java.io.InvalidClassException: com.sap.engine.frame.NestedProperties; local class incompatible: stream classdesc serialVersionUID = -6939830547472149951, local class serialVersionUID = -7651711313372906445 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
Caused by: java.io.InvalidClassException: com.sap.sdo.impl.objects.strategy.AbstractDataStrategy; local class incompatible: stream classdesc serialVersionUID = 8093200772571014309, local class serialVersionUID = -92679364266290821 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
Caused by: java.io.InvalidClassException: com.sap.engine.services.security.exceptions.SecurityResourceAccessor; local class incompatible: stream classdesc serialVersionUID = -4183425546803847845, local class serialVersionUID = 1 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
Keywords
- Caused by: java.io.InvalidClassException
- InvalidClassException
- serialVersionUID
- classdesc
Description
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:
http://www.javapractices.com/topic/TopicAction.do?Id=45
http://www.jdom.org/pipermail/jdom-interest/2000-September/002123.html
Solution
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
N/A