I have been having problems with the deserialization of an encoded serialized JFreeChart object.
Here's the scoop:
I am serializing a JFreeChart instance, and encapsulating it in an application using the base64 encoder in the org.jfree.xml.util library. Later on, when the JFreeChart instance needs to be used again, I decode the data (using the base64 decoder), write out the data as a file, then try to deserialize it.
Doing some initial investigative work, it appears to me that the original serialized JFreeChart file and the resulting decoded file are different (Their sizes are the same, although diffing them shows minor differences here and there), and I am unable to deserialize it correctly.
Anyone experience this? Does the base64 encoder have a problem with binaries?
jcommon-1.0.9
jcommon-xml-1.0.9
jfreechart-1.0.5
Base64 encoder with serialized JFreeChart
If it helps any, this is the actual error I get:
org.jfree.chart.plot.Plot; local class incompatible: stream classdesc serialVersionUID = -8831571430103695388, local class serialVersionUID = -8831571430103671324
Which doesn't make sense to me because the object that was serialized was JFreeChart object?
This is the line of code where it barfs:
JFreeChart chart;
chart = (JFreeChart)in.readObject();
Keep in mind that the serialized JFreeChart object had been encoded using the base64 encoder, then decoded, written out to a file, and is now being deserialized.
org.jfree.chart.plot.Plot; local class incompatible: stream classdesc serialVersionUID = -8831571430103695388, local class serialVersionUID = -8831571430103671324
Which doesn't make sense to me because the object that was serialized was JFreeChart object?
This is the line of code where it barfs:
JFreeChart chart;
chart = (JFreeChart)in.readObject();
Keep in mind that the serialized JFreeChart object had been encoded using the base64 encoder, then decoded, written out to a file, and is now being deserialized.
Hi,
this is not necessarily a error in the decoder. This sounds more or less like you are deserializing the chart-object on a different system with different versions of the library. The serialVersionUID of -8831571430103671324 is the declared Id in the sources of JFreeChart (since version 1.0.0-rc1).
So the serialized object is most likely very old and was created with an pre 1.0.0 version of JFreeChart. Serialized objects do not survive structural changes to their underlying classes - that's why no one is using them for long term storage.
Have fun,
said Thomas
this is not necessarily a error in the decoder. This sounds more or less like you are deserializing the chart-object on a different system with different versions of the library. The serialVersionUID of -8831571430103671324 is the declared Id in the sources of JFreeChart (since version 1.0.0-rc1).
So the serialized object is most likely very old and was created with an pre 1.0.0 version of JFreeChart. Serialized objects do not survive structural changes to their underlying classes - that's why no one is using them for long term storage.
Have fun,
said Thomas
Thank you for your feedback, however I'm not entirely sure that's the case.
I have successfully serialized and deserialized a JFreeChart instance, without any encoding. But when the encoder is used, in this order:
serialize
encode
decode
deserialize
It won't properly deserialize. I am not trying to deserialize an old JFreeChart instance either. I have written a test app that does this logic as seen above, and still I can't get it to work (The code is proprietary, otherwise I would post it).
It may be worth noting that I have also tried a different encoder, and still get this same error. With this in mind, I would agree it may not be the encoder.
Any other thoughs?
I have successfully serialized and deserialized a JFreeChart instance, without any encoding. But when the encoder is used, in this order:
serialize
encode
decode
deserialize
It won't properly deserialize. I am not trying to deserialize an old JFreeChart instance either. I have written a test app that does this logic as seen above, and still I can't get it to work (The code is proprietary, otherwise I would post it).
It may be worth noting that I have also tried a different encoder, and still get this same error. With this in mind, I would agree it may not be the encoder.
Any other thoughs?