The error does suggest that something in your collection is null (but
the JAXB RI should do a better job of detecting this error in more
helpful way --- dying with NPE just doesn't cut it.)
I noticed from the stack trace that somewhere in the document tree, you
must be using a class that has @XmlValue in it, probably like:
class Foo {
@XmlValue String value;
}
(I don't know if its type is string.) It's dying because an object of
this class doesn't have the value inside it.
It just so happens that I closed issue #217 yesterday
https://jaxb.dev.java.net/issues/show_bug.cgi?id=217
and this fix is probably related to your bug, so I suggest you try the
latest and see what happens.
Dmitri Colebatch wrote:
> Hi all,
>
> I'm not sure if this is a JAXB bug or not, I've hit it in the past but
> have never really been able to nail down where it comes from. When I
> try to reproduce it out of container I cant. Given that here in
> Melbourne its 6pm on a Friday night I figured I might throw this out
> there in case anyone has any tips.
>
> I get the following stack trace when marshalling a relatively simple
> element (schema snipped at end of email). My content is fairly
> simple, I've got a list of strings that I stick in the object and then
> try to marshall it. I fear that this is somehow related to some
> classloader nasties but don't know the internals of JAXB well enough
> to start digging (certainly not on a Friday afternoon anyway). Here's
> my stack trace:
>
> java.lang.NullPointerException
> at com.sun.xml.bind.v2.runtime.output.SAXOutput.text(SAXOutput.java:114)
> at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:288)
> at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:172)
> at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:171)
> at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:206)
> at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl$TransducerImpl.writeLeafElement(RuntimeClassInfoImpl.java:297)
> at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:206)
> at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:62)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:98)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:127)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:244)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:251)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:33)
> at com.sun.xml.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:78)
> at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:101)
> at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
> at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:594)
> at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
> at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:293)
> at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:594)
> at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:114)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:98)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:127)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:244)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:251)
> at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:33)
> at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:455)
> at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)
> at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
> at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77)
> at com.toyota.ibus.common.ws.SOAPMessage.stringify(SOAPMessage.java:468)
> at com.toyota.ibus.common.ws.SOAPMessage12.stringify(SOAPMessage12.java:81)
>
> Anyone have any thoughts on what might be causing this? The data in
> my object is perfectly normal (31 strings in a list, none of them
> null).
>
> cheers
> dim
>
> schema snippet:
>
> <xsd:element name="GetCurrentMessagesRsp">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="MessageVersion" minOccurs="0"
> maxOccurs="unbounded" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com