users@glassfish.java.net

Re: JAXB NullPointerException With Nested HashMap in GF 3.1.2

From: Martin Grebac <martin.grebac_at_oracle.com>
Date: Tue, 10 Apr 2012 09:36:13 +0200

Hi,
  it would help if you could please file an issue into JAXB issue
tracker (http://jaxb.java.net) and attach the reproducible testcase
there. We'll look into it. Thanks,
  MartiNG

On 4/10/12 8:01 AM, forums_at_java.net wrote:
> It seems that JAXB 2.2.5 is causing a NPE where versions 2.2.4 and
> older did
> not. I wrote a simple test EJB inside a Maven project to demonstrate the
> problem and attached the files. I have a class named HashMapWrapper that
> contains a HashMap and provides getters and setters into that map. In the
> case where an Object value is a nested HashMapWrapper, JAXB throws a
> NPE when
> unmarshaling the XML. I've taken the same test EJB and deployed it in GF
> 3.1.1 where it works fine, but when I deploy it in 3.1.2, it breaks.
> Is it
> possible (or even a good idea) to either downgrade the version of JAXB
> in my
> local glassfish installation or explicitly use an older version where
> I do
> this kind of marshaling? Could this be a bug or just an inconsistency
> in my
> code that wasn't being caught in earlier versions? The XML it is
> attempting
> to unmarshal is shown below and at the bottom is the exception that is
> thrown. Any help would be appreciated. Thanks! Nate <?xml version="1.0"
> encoding="UTF-8" standalone="yes"?> NestedKey NameKey NestedWrapper
> NameKey
> OuterWrapper Caused by: java.lang.NullPointerException at
> com.myexample.HashMapWrapper$JaxbAccessorM_getMap_setMap_java_util_HashMap.set(MethodAccessor_Ref.java:60)
>
> at
> com.sun.xml.bind.v2.runtime.property.SingleMapNodeProperty$1.leaveElement(SingleMapNodeProperty.java:183)
>
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:526)
>
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:158)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
>
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
>
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:218)
>
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:190)
>
> at
> javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:172)
>
> at
> javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:219)
>
> at com.myexample.HashMapWrapper.unmarshal(HashMapWrapper.java:89) at
> com.myexample.TestBean.testUnmarshal(TestBean.java:29) at
> com.myexample.TestBean.init(TestBean.java:18)
>
> --
>
> [Message sent by forum member 'cerebrus']
>
> View Post: http://forums.java.net/node/884975
>
>
>

-- 
Martin Grebac, Metro/JAXWS/JAXB RI Lead
Oracle Czech, Prague
http://blogs.oracle.com/mgrebac
ICQ: 93478885