[ 
https://issues.apache.org/jira/browse/CXF-2779?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chris Wilson updated CXF-2779:
------------------------------

    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|http://www.caucho.com/resin-3.1/doc/jaxb-annotations.x...@xmlattribute]
 says:

bq. 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:

{code}
@XmlRootElement
class Bean {
  @XmlAttribute("sample-field")
  private String _myField;
}
{code}

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.

  was:
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 
[http://www.caucho.com/resin-3.1/doc/jaxb-annotations.x...@xmlattribute|Caucho 
documentation] says:

bq. 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:

{code}
@XmlRootElement
class Bean {
  @XmlAttribute("sample-field")
  private String _myField;
}
{code}

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.


> CXF ignores @XmlAttribute when serializing exception
> ----------------------------------------------------
>
>                 Key: CXF-2779
>                 URL: https://issues.apache.org/jira/browse/CXF-2779
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.2.7
>            Reporter: Chris Wilson
>         Attachments: CxfExceptionFieldPropagationTest.java
>
>
> 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|http://www.caucho.com/resin-3.1/doc/jaxb-annotations.x...@xmlattribute]
>  says:
> bq. 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:
> {code}
> @XmlRootElement
> class Bean {
>   @XmlAttribute("sample-field")
>   private String _myField;
> }
> {code}
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to