Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355544 - @XmlElementRef should support not specifying a name for abstract type with @XmlRootElements
Summary: @XmlElementRef should support not specifying a name for abstract type with @X...
Status: CLOSED DUPLICATE of bug 355970
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Denise Smith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-23 13:52 EDT by Paul Fullbright CLA
Modified: 2022-06-09 10:09 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fullbright CLA 2011-08-23 13:52:50 EDT
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.
Comment 1 Denise Smith CLA 2011-09-15 14:07:05 EDT

*** This bug has been marked as a duplicate of bug 355970 ***
Comment 2 Paul Fullbright CLA 2011-09-15 14:12:43 EDT
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.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:04:56 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:09:51 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink