Hello everyone, I am a new to XStream user and I have an issue that might be very simple but I am not able to figure it out.
Let's say I have the following XML: <main id="foo"> <name>bar</name> </main> I would like to use the JavaBeanConverter to force the unmarshalling to go through my setters but when I register the JavaBeanConverter, my XStreamAsAttribute annotations seem to stop working. Here is my code so far: import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAsAttribute; import com.thoughtworks.xstream.converters.javabean.JavaBeanConverter; @XStreamAlias("main") public class Main { public static void main(String[] args) { XStream xstream = new XStream(); xstream.autodetectAnnotations(true); xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()), XStream.PRIORITY_VERY_LOW); xstream.processAnnotations(Main.class); System.out.println(xstream.fromXML("<main id=\"foo\"><name>bar</name></main>")); } @XStreamAsAttribute private String id; private String name; public String getId() { return id; } public void setId(String id) { System.out.println("Called setId()"); this.id = id; } public String getName() { return name; } public void setName(String name) { System.out.println("Called setName()"); this.name = name; } @Override public String toString() { return "Main [id=" + id + ", name=" + name + "]"; } } With the JavaBeanConverter registered, I see the print message in setName() but not the one in setId() and the id field remains null. If I comment it out, I do not go through the setters but id's value is correct. What am I missing? Thanks in advance for your help. Cheers, LP