[JAXP-79] NPE from marshalling an IDREF that point to a missing ID attribute value Created: 19/Mar/14  Updated: 19/Mar/14  Resolved: 19/Mar/14

Status: Closed
Project: jaxp
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: tuomas_kiviaho Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


NPE is thrown prematurely in case of an id attribute being null instead of a more appropriate validation event (Object "..." is found in an IDREF property but this object doesnt have an ID.). In order to fix this see AttributeProperty.serializeAttributes method that deals with the null correctly.

It seems that other people have had to deal this problem before (http://stackoverflow.com/questions/10705532/in-jaxb-marshalling-how-to-identify-which-child-element-caused-jaxb-marshallin). I guess that pinpointing of the cause can be quite problematic with the current behavior.

  • * * StackTrace * *

AttributeProperty<BeanT>.getIdValue(BeanT) line: 128
ClassBeanInfoImpl<BeanT>.getId(BeanT, XMLSerializer) line: 322
TransducedAccessor$IDREFTransducedAccessorImpl<BeanT,TargetT>.print(BeanT) line: 290
TransducedAccessor$IDREFTransducedAccessorImpl<BeanT,TargetT>(DefaultTransducedAccessor<T>).writeLeafElement(XMLSerializer, Name, T, String) line: 69
SingleElementLeafProperty<BeanT>.serializeBody(BeanT, XMLSerializer, Object) line: 130
ClassBeanInfoImpl<BeanT>.serializeBody(BeanT, XMLSerializer) line: 361
XMLSerializer.childAsXsiType(Object, String, JaxBeanInfo, boolean) line: 696

Comment by Joe Wang [ 19/Mar/14 ]

This is a JAXB issue. Please file bug in JAXB IssueTracker at https://java.net/jira/browse/JAXB/. Thanks.

Generated at Tue Apr 25 01:12:06 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.