Bug 412957 - Unhandled NPE in oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:87)
Summary: Unhandled NPE in oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelation...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-15 08:20 EDT by Ondrej Zizka CLA
Modified: 2022-06-09 10:04 EDT (History)
2 users (show)

See Also:


Attachments
test src (1.76 KB, application/zip)
2013-07-15 08:20 EDT, Ondrej Zizka CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Zizka CLA 2013-07-15 08:20:45 EDT
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)
Comment 1 Denise Smith CLA 2013-07-15 10:45:48 EDT
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.
Comment 2 Ondrej Zizka CLA 2013-07-15 12:21:47 EDT
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.
Comment 3 Ondrej Zizka CLA 2013-07-15 16:53:15 EDT
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.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink