Community
Participate
Working Groups
Consider the following classes: ----- @XmlRootElement @XmlSeeAlso({Dog.class, Cat.class}) public class Animal { public String name; } @XmlRootElement public class Cat extends Animal { public int sleepTime; public Dog enemy; } public class Dog extends Animal { public String barkLevel; } ----- And the following instance document: ----- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <animal xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cat"> <name>Fluffy</name> <sleepTime>10</sleepTime> <enemy> <name>Buster</name> <barkLevel>LOUD</barkLevel> </enemy> </animal> ----- When this document is unmarshalled using MOXy, a JAXBElement is returned, however the RI will unmarshal this as a true Cat object.
This bug is captured in the following test case: org.eclipse.persistence.testing.jaxb.javadoc.xmlseealso.XmlSeeAlsoTest (Praba is working on these tests and they have not been checked in yet, the above test class name may change)
While I was trying out JDK6-JAXB annotation examples, I got few failures with XmlSeeAlso example. EclipseLink build: 2.3.0 (April 23) JDK: 1.6.0_20 Test Class: org.eclipse.persistence.testing.jaxb.javadoc.xmlseealso.XmlSeeAlsoTest Following unmarshall tests failed: --------------------- Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testXMLToObjectFromInputStream Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testRoundTrip Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testXMLToObjectFromURL Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testXMLToObjectFromXMLStreamReader Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testXMLToObjectFromXMLEventReader Java Project Source w/SAX Parsing: XmlSeeAlsoTes: testUnmarshallerHandler Stack trace were similar to following: --------------------------------------- junit.framework.AssertionFailedError: expected:<org.eclipse.persistence.testing.jaxb.javadoc.xmlseealso.Cat@2fa918d5> but was:<javax.xml.bind.JAXBElement@49bdc9d8> at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.failNotEquals(Assert.java:283) at junit.framework.Assert.assertEquals(Assert.java:64) at junit.framework.Assert.assertEquals(Assert.java:71) at org.eclipse.persistence.testing.oxm.mappings.XMLMappingTestCases.xmlToObjectTest(XMLMappingTestCases.java:269) at org.eclipse.persistence.testing.jaxb.JAXBTestCases.xmlToObjectTest(JAXBTestCases.java:430) at org.eclipse.persistence.testing.jaxb.JAXBTestCases.testXMLToObjectFromInputStream(JAXBTestCases.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at
*** Bug 344057 has been marked as a duplicate of this bug. ***
Created attachment 194631 [details] testmodel and testcase to reproduce the bug
Created attachment 194633 [details] testmodel and testcase to reproduce the bug
Created attachment 194634 [details] testmodel and testcase to reproduce the bug
Created attachment 194635 [details] testcase to reproduce the bug
Created attachment 216230 [details] MOXy - Test Cases
Created attachment 216235 [details] MOXy - Test Cases
Created attachment 216236 [details] MOXy - Test Cases
Fix checked into 2.4.0 at revision: 11488 Fix checked into trunk at revision: 11489 Code reviewed by: Rick Barkhouse --- Resolution There is a difference in how MOXy and the RI handle this use case. As MOXy is able to round trip the following document and the RI is not, I believe the MOXy behaviour to be the correct behaviour for this use case. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <animal xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cat"> <name>Fluffy</name> <sleepTime>10</sleepTime> <enemy> <name>Buster</name> <barkLevel>LOUD</barkLevel> </enemy> </animal> Note both MOXy and the RI handle the following document the same: <cat> <name>Fluffy</name> <sleepTime>10</sleepTime> <enemy> <name>Buster</name> <barkLevel>LOUD</barkLevel> </enemy> </cat>
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink