Community
Participate
Working Groups
Created attachment 233476 [details] test src I've set up few tests to test inheritance. Some of them are (were) wrong as I was learning. Anyway, one test failed with NPE, see below. Attaching the test sources zip. Exception Description: An error occurred unmarshalling the document Internal Exception: java.lang.NullPointerException] at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:980) at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:588) at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:182) at org.jboss.loom.test.jaxb.beans.extractorInner.JaxbInheritance_XmlClassExtractorInner_Test.testUnmarshall(JaxbInheritance_XmlClassExtractorInner_Test.java:28) Caused by: Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException Exception Description: An error occurred unmarshalling the document Internal Exception: java.lang.NullPointerException at org.eclipse.persistence.exceptions.XMLMarshalException.unmarshalException(XMLMarshalException.java:113) at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.convertSAXException(SAXUnmarshaller.java:996) at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:903) at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:659) at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:585) Caused by: java.lang.NullPointerException at org.eclipse.persistence.internal.oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:87) at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.startElement(XMLCompositeCollectionMappingNodeValue.java:184) at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.startElement(UnmarshalRecordImpl.java:834) at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parseEvent(XMLStreamReaderReader.java:132) at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:99) at org.eclipse.persistence.internal.oxm.record.XMLStreamReaderReader.parse(XMLStreamReaderReader.java:86) at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:895)
I only seem able to reproduce the NPE on unmarshal if I remove the @XmlSeeAlso annotation from Base @XmlClassExtractor(BaseClassExtractor.class) @XmlSeeAlso({SubFoo.class, SubBar.class}) public static abstract class Base {} If there is no @XmlSeeAlso annotation then the subclasses aren't loaded into the context and I can reproduce the NPE. In this case we should throw a better exception during the unmarshal.
Possible; note that in the code, the sub classes do not extend Base. That could have similar effect. I'm not sure if I zipped that wrong or fixed version (with "extends Base"). Maybe, for that case, if you want to be super-user-friendly (which I personally appreciate in any project), could do the analysis of @XmlSeeAlso, and issue a WARN if the classes mentioned have nothing to do with the annotated class.
Note for reproducing: So the reason was, IDE added an import of BaseClassExtractor from another package when copying from it. Then I changed the copied BaseClassExtractor, but MOXy (correctly) used the other one. So the Base and used subtypes were unrelated.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink