Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
2.2.7
-
None
Description
JAXBEncoderDecoder#unmarshallException} doesn't normally write to private fields, so exception data isn't propagated, unless:
- either the
{@link @XmlAccessorType}
annotation is present on the class and used to set the default access method to something other than the default XmlAccessType#PUBLIC_MEMBER,
- or the
{@link XmlAttribute}
annotation is present on the individual private members that you want to be serialized.
The Caucho documentation says:
Adding @XmlAttribute to a private field will mark that field as serializable.
and they give the following example which clearly implies that no accessors are required:
@XmlRootElement class Bean { @XmlAttribute("sample-field") private String _myField; }
Nevertheless:
- JAXBEncoderDecoder#marshallException calls org.apache.cxf.jaxb.JAXBContextInitializer#isFieldAccepted to see whether the field should be copied
- that method fails to check for the XmlAttribute annotation on the field
- so its value is never serialized or deserialized
and the attached test case fails unless:
- either a public getter and setter are provided to turn the field into a property,
- or the access type is changed to something other than PUBLIC_MEMBER.