Community
Participate
Working Groups
For the following object model: @XmlRootElement(name="root") public class Root { @XmlElementRef(type=Foo.class) public List foos; } @XmlSeeAlso({ FooA.class, FooB.class }) public abstract class Foo { @XmlValue public String value; } @XmlRootElement(name="foo-a") public class FooA extends Foo {} @XmlRootElement(name="foo-b") public class FooB extends Foo {} when attempting to marshal a document, I get the following exception: javax.xml.bind.JAXBException: Exception Description: Invalid XmlElementRef on property foos on class jaxbtest.model.Root. Referenced Element not declared. ... This is pretty much Example 1 (Ant Task example) (except the type is specified in the @XmlElementRef annotation, not the java field) in the @XmlElementRef javadocs, and is fully supported with Metro.
*** This bug has been marked as a duplicate of bug 355970 ***
Is this really a duplicate? The problem with the other use case was that the JAXB context wasn't including other types (I think). Here there is an error if the user doesn't specify a name, which isn't used anyway.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink