Community
Participate
Working Groups
Build Identifier: 2.3.0-SNAPSHOT (20110202.060516-27) The class is in a package with @XmlAccessorType(XmlAccessType.NONE) If the class with an abstract superclass (which is not annotated at all) has a field annotated with @XmlValue, the following exception happens during marshalling: org.eclipse.persistence.exceptions.JAXBException Exception Description: The property or field s can not be annotated with XmlValue since it is a subclass of another XML-bound class. I think it's a rare situation, but I'm working on the legacy code and there is such special case. Reproducible: Always Steps to Reproduce: See the attached test case.
Created attachment 188165 [details] Test Case
Blaise, Is this a case where MOXy supports this, but the JAXB spec does not? In section 8.9.10.2: The containing class must not extend another class (other than java.lang.Object). Though in section 8.7.1.2 I see: if the class, subClass, derives from another XML-bound class, baseClass directly or indirectly (other than java.lang.Object), then the subClass must not contain a mapped property or field annotated with @XmlValue annotation. These 2 seems to be in conflict or maybe you can explain to me what is meant here. One says it must not extend another class the other says it can't extend another *XML-bound* class.
Karen, The test case should not work as is. But there is still a bug because if the Ancestor class is marked @XmlTransient then it is no longer an XML-bound class: package moxy.test; import javax.xml.bind.annotation.XmlTransient; @XmlTransient public abstract class Ancestor { public static String CORRECT_MARSHALLED_FOO = "<Foo><s>test</s></Foo>"; public static String CORRECT_MARSHALLED_FOO_XMLVALUE = "<Foo>test</Foo>"; private String foo2; public String getFoo2() { return foo2; } }
(In reply to comment #3) > Karen, > > The test case should not work as is. But there is still a bug because if the > Ancestor class is marked @XmlTransient then it is no longer an XML-bound class: > I thought when the package was marked with @XmlAccessorType(XmlAccessType.NONE), then none of the classes without explicit JAXB annotations were XML bound.
Created attachment 194616 [details] MOXy - Test Cases
Created attachment 194628 [details] MOXy - Test Cases
Created attachment 194629 [details] MOXy - Fix
Created attachment 194737 [details] MOXy - Test Cases
Created attachment 194738 [details] MOXy - Fix Instead of checking to see if there is a parent class, check to see if a parent class has a field/property mapped to something other than an attribute.
Fix checked into trunk at rev: 9308 Code reviewed by: Matt MacIvor
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink