JAXBContextInitializer ignores some javax.xml.bind Annotations
--------------------------------------------------------------

                 Key: CXF-4036
                 URL: https://issues.apache.org/jira/browse/CXF-4036
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 2.5.1, 2.4.3
            Reporter: d ferbas


{{org.apache.cxf.jaxb.JAXBContextInitializer}} ignores {{@XmlTransient}} and 
{{@XmlJavaTypeAdapter}} at some locations. This can lead to fatal exceptions 
because it tries to analyze (add) classes that are not intended to be 
xml-marshalled.

{{@XmlTransient}} is ignored if placed on a setter (when using 
{{@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER))}}. Jaxb (tested with jdk 
1.6.0_18) honors this no matter if placed on getter or setter of the property.
The problem could be in 
{{org.apache.cxf.jaxb.JAXBContextInitializer.isMethodAccepted(Method, 
XmlAccessType)}} where a getter is accepted even if its setter has 
{{@XmlTransient}}. As a workaround the annotation has to be placed on the 
getter.

{{@XmlJavaTypeAdapter}} is ignored if placed on class level (that again is OK 
for Jaxb). 
The problem could be in 
{{org.apache.cxf.jaxb.JAXBContextInitializer.addClass(Class<?>)}} where the 
@XmlJavaTypeAdapter annotation is checked only if the class is an interface, 
but not otherwise (especially the superclass is added w.o. checking if there is 
a typeadapter to use). 
As a workaround the annotation can be placed on the using field/property of the 
type. But obviously this leads to duplication if the class with adapter is used 
more than once.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to