title: JAXB marshaller throwing NullPointerException when upgrading from Java 6 to Java 7 in XMLSerializer
body: <p>I've scoured the interwebs for a solution but I am at a loss so I'm hoping someone can point me in the right direction here.</p>
  
  <p>I've been tasked with upgrading an app, which makes use of JAXB2, to Java 7.</p>
  
  <p>Since I understand JVM 7 can run Java 6 compiled code, that's what I tried first, and encountered a Null Pointer Exception in the com.sun.xml.internal.bind.v2.runtime.XMLSerializer class.</p>
  
  <p>I then recompiled the app in Java 7 and ran again and same issue.</p>
  
  <p>I am using following Oracle JDK: <strong>Java SE 7u51</strong>
  The app also uses Spring OXM which delegates to JAXB.</p>
  
  <p>Here is the stack Trace of Null Pointer Exception that occurs when marshal is called on the JAXB Marshaller instance:</p>
  
  <pre><code>&gt; java.lang.NullPointerException    at
  &gt; com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:627)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:108)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:343)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:685)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:54)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:157)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:144)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:343)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:582)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:325)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:103)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:144)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:343)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:582)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:325)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:483)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
  &gt;   at
  &gt; com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
  &gt;   at
  &gt; org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:648)
  </code></pre>
  
  <p>Perhaps there is some additional configuration I am missing?</p>
  
  <p>Any help appreciated.  Will provide any more info as required.</p>
  
  <p>Thank you</p>