I am using Eclipselink 2.3.2 as my JAXB (JSR-222) provider. I have created a generic list which consists of a list of items and a set of Pagination Links.
import java.util.List;
import javax.xml.bind.annotation.*;
@XmlRootElement(name = "listdata")
public class ListEntity<T> {
@XmlElementRef
public List<T> data;
@XmlElementRef
public PaginationLinks links;
public ListEntity(List<T> data) {
this.data = data;
}
public ListEntity() {
}
}
My actual Entity
@XmlRootElement(name="authorization")
public class AuthorizationDTO {
@XmlElement
public String referenceNumber;
}
So, after creation of the list, when I try to marshall it, I get the following error. Works fine with @XmlElement for List data but obviously cannot be used as it creates the Object representation
Caused by: Exception [EclipseLink-50006] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Invalid XmlElementRef on property data on class com.ofss.fc.botg.infra.model.ListEntity. Referenced Element not declared.