users@jaxb.java.net

Re: NullPointer on creating JAXBContext

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 30 Jul 2007 12:26:05 -0700

Yeah, this NPE looks familiar. I'm pretty sure I fixed this at some
point in 2.1.x (or 2.0.x? don't remember...)

Marc Logemann wrote:
> Hi,
>
> replying to myself.... i upgraded to latest JAXB version (2.1.3) and
> the error is history now. I also did a full build to be sure that
> there is no old class or something in my appserver, so i am not 100%
> sure if this is a version thingy but it seems likely.
>
> Marc
>
> Am 26.06.2007 um 22:41 schrieb Marc Logemann:
>
>> Hi,
>>
>> since a few days i am getting a NullPointer on creating a
>> JAXBContext for a specific class. Has somebody an idea whats going
>> on there? Below is the stack, the annotated class where i want a
>> context of and the call to JAXB.
>>
>> Note: i created the annotated class by using the compiler to create
>> a class from an XSD.
>>
>>
>> Call:
>> ------
>>
>> JAXBContext context = JAXBContext.newInstance(SpedDetShow.class);
>>
>> Class:
>> ---------
>>
>> import javax.xml.bind.annotation.XmlAccessType;
>> import javax.xml.bind.annotation.XmlAccessorType;
>> import javax.xml.bind.annotation.XmlElement;
>> import javax.xml.bind.annotation.XmlRootElement;
>> import javax.xml.bind.annotation.XmlType;
>>
>>
>> /**
>> * <p>Java class for anonymous complex type.
>> *
>> * <p>The following schema fragment specifies the expected content
>> contained within this class.
>> *
>> * <pre>
>> * &lt;complexType>
>> * &lt;complexContent>
>> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}
>> anyType">
>> * &lt;choice>
>> * &lt;element ref="{http://as777.bartolini.it}Spedizione"/>
>> * &lt;element ref="{http://as777.bartolini.it}Errore"/>
>> * &lt;/choice>
>> * &lt;/restriction>
>> * &lt;/complexContent>
>> * &lt;/complexType>
>> * </pre>
>> *
>> *
>> */
>> @XmlAccessorType(XmlAccessType.FIELD)
>> @XmlType(name = "", propOrder = {
>> "spedizione",
>> "errore"
>> })
>> @XmlRootElement(name = "sped_det_show")
>> public class SpedDetShow {
>>
>> @XmlElement(name = "Spedizione")
>> protected Spedizione spedizione;
>> @XmlElement(name = "Errore")
>> protected Errore errore;
>>
>> /**
>> * Gets the value of the spedizione property.
>> *
>> * @return
>> * possible object is
>> * {_at_link Spedizione }
>> *
>> */
>> public Spedizione getSpedizione() {
>> return spedizione;
>> }
>>
>> /**
>> * Sets the value of the spedizione property.
>> *
>> * @param value
>> * allowed object is
>> * {_at_link Spedizione }
>> *
>> */
>> public void setSpedizione(Spedizione value) {
>> this.spedizione = value;
>> }
>>
>> /**
>> * Gets the value of the errore property.
>> *
>> * @return
>> * possible object is
>> * {_at_link Errore }
>> *
>> */
>> public Errore getErrore() {
>> return errore;
>> }
>>
>> /**
>> * Sets the value of the errore property.
>> *
>> * @param value
>> * allowed object is
>> * {_at_link Errore }
>> *
>> */
>> public void setErrore(Errore value) {
>> this.errore = value;
>> }
>>
>> }
>>
>>
>> stack:
>> ---------
>> java.lang.NullPointerException
>> at
>> com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName
>> (PropertyInfoImpl.java:287)
>> at
>> com.sun.xml.bind.v2.model.impl.PropertyInfoImpl.calcXmlName
>> (PropertyInfoImpl.java:260)
>> at
>> com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl.getTypes
>> (ElementPropertyInfoImpl.java:100)
>> at
>> com.sun.xml.bind.v2.model.impl.RuntimeElementPropertyInfoImpl.getTypes
>> (RuntimeElementPropertyInfoImpl.java:50)
>> at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl
>> $1.size(ElementPropertyInfoImpl.java:42)
>> at java.util.AbstractList$Itr.hasNext(AbstractList.java:416)
>> at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
>> (ModelBuilder.java:139)
>> at
>> com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
>> (RuntimeModelBuilder.java:49)
>> at
>> com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
>> (RuntimeModelBuilder.java:41)
>> at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
>> (ModelBuilder.java:189)
>> at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
>> (ModelBuilder.java:204)
>> at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run
>> (JAXBContextImpl.java:352)
>> at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run
>> (JAXBContextImpl.java:350)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet
>> (JAXBContextImpl.java:349)
>> at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>
>> (JAXBContextImpl.java:215)
>> at com.sun.xml.bind.v2.ContextFactory.createContext
>> (ContextFactory.java:76)
>> at com.sun.xml.bind.v2.ContextFactory.createContext
>> (ContextFactory.java:55)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke
>> (NativeMethodAccessorImpl.java:39)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke
>> (DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at javax.xml.bind.ContextFinder.newInstance
>> (ContextFinder.java:210)
>> at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
>> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:
>> 574)
>> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:
>> 522)
>> at
>> de.netversys.process.bartolini.BartoliniTrackTraceResolver.traceParcel
>> (BartoliniTrackTraceResolver.java:61)
>> ...
>>
>>
>>
>> THX
>>
>>
>> --
>> regards
>> Marc Logemann
>> [blog] http://www.logemann.org
>> [busn] http://www.logentis.de
>>
>>
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com