java serialization problems with different JVMs
- by Alberto
I am having trouble using serialization in Java. I've searched the web for a solution but haven't found an answer yet.
The problem is this - I have a Java library (I have the code and I export it to an archive prior to executing the code) which I need to use with two differents JVMs. One JVM is on the server (Ubuntu, running Java(TM) JRE SE Runtime Environment (build 1.7.0_09-b05)) and the other on Android 2.3.3. I compiled the library in Java 1.6.
Now, I am trying to import to the client, an object exported from the server, but I receive this error:
java.io.InvalidClassException:
[Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;;
Incompatible class (SUID):
[Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;: static
final long serialVersionUID =-359311387972759020L; but expected
[Lweka.classifiers.functions.MultilayerPerceptron$NeuralEnd;: static
final long serialVersionUID =1920571045915494592L;
I do have an explicit serial version UID declared on the class MultilayerPerceptron$NeuralEnd, like this:
protected class NeuralEnd extends NeuralConnection {
private static final long serialVersionUID = 7305185603191183338L;
}
Where NeuralConnection implements the java.io.Serializable interface. If I do a serialver on MultilayerPerceptron$NeuralEnd I receive the serialVersionUID which I declared. So, why have both JVMs changed this value? Can you help me?
Thanks,
Alberto