xs = new XStream();
xs.setMode(XStream.NO_REFERENCES);
xs.ignoreUnknownElements();
xs.registerConverter(new JavaBeanConverter(xs.getMapper(),
new TransientRespectingBeanProvider()), XStream.PRIORITY_VERY_LOW);
Yesterday I added a String field to one of my classes and serialised it. An older version of the app was not able to deserialise the xml.
com.thoughtworks.xstream.converters.ConversionException: No field 'materialNrVersion' found in class 'com.company.ProjectConfiguration' : No field 'materialNrVersion' found in class 'com.company.ProjectConfiguration'
---- Debugging information ----
message : No field 'materialNrVersion' found in class 'com.company.ProjectConfiguration'
cause-exception : com.thoughtworks.xstream.converters.reflection.MissingFieldException
cause-message : No field 'materialNrVersion' found in class 'com.company.ProjectConfiguration'
class : com.company.ProjectConfiguration
required-type : com.company.ProjectConfiguration
converter-type : com.thoughtworks.xstream.converters.javabean.JavaBeanConverter
line number : 192
version : 1.4.7
Should I be doing this a different way?
UPDATE If I comment out the registerConverter call, then the unknown fields are ignored. The JavaBeanConverter seems to be affecting the way the ignoreUnknownElements is handled. The TransientRespectingBeanProvider is intended to ignore properties which have a @Transientannotation.
Can anyone suggest a solution or workaround? An alternative approach to the @Transient issue?