users@jaxb.java.net

Re: NPE in SAXOutput.text

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Mon, 14 Aug 2006 12:24:59 +1000

Hi Kohsuke,

This of course shouldn't come as a surprise, but you were spot on. I
was foolishly assuming that the problem must be related to my code,
rather than our framework code which in this case was adding a
WS-Addressing To header with a null value. I haven't tried the latest
code, but take your word for it that you've changed it to throw a more
meaningful exception. In the meantime I'll fix my code (o:

cheers
dim

On 8/12/06, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_sun.com> wrote:
>
> 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
>
>
>