Community
Participate
Working Groups
Given the following object model: package forum6928521; import java.util.Random; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlID; public class Small { private String xmlId; @XmlID @XmlAttribute public String getXmlId() { if (xmlId == null) xmlId = "small" + new Random().nextInt(); return xmlId; } public void setXmlId(String id) { this.xmlId = id; } } and package forum6928521; public class Big extends Small { // Code } The following exception is incorrectly being thrown since the Big class should inherit the @XmlID from the parent class: Exception Description: Invalid XmlIDREF on property [big]. Class [forum6928521.Big] is required to have a property annotated with XmlID.] at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:825) at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:136) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:142) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:129) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:93) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at forum6928521.Test2.main(Test2.java:25) Caused by: Exception [EclipseLink-50017] (Eclipse Persistence Services - 2.3.1.qualifier): org.eclipse.persistence.exceptions.JAXBException Exception Description: Invalid XmlIDREF on property [big]. Class [forum6928521.Big] is required to have a property annotated with XmlID. at org.eclipse.persistence.exceptions.JAXBException.invalidIdRef(JAXBException.java:184) at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.finalizeProperties(AnnotationsProcessor.java:769) at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:236) at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147) at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:822) ... 14 more
Created attachment 200843 [details] Proposed changes and tests
Fixed in trunk (2.4) and 2.3.1 Changed annotationsprocessor so subtypes know about there parent`s XML ID Property if one is set.
Added new test in jaxb.xmlidref
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink