Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] XMLTransformationMapping problem

Hi Magnus,

I don't think there's anything wrong with how you're setting up your mapping. I took a look at the code and I think this is a bug with our handling of namespaces here.

It looks like in the case that the XML document declares a namespace, and then that namespace goes out of scope, the prefix remains in the UnmarshalNamespaceResolver, but there's no longer a namespace uri associated with it. This causes the getNamespace() method to return null, which isn't guarded against in XMLTransformationRecord/NamespaceResolver which is causing your NullPointerException.

I was able to reproduce this on our end by modifying one of the control documents our test cases. I'll log a bug against this and should have a fix fairly soon.

-Matt

On 29/06/2010 7:25 AM, Magnus Heino wrote:

Hi.

I have a bunch of attriutes gml:id="someid" in my xml that I need to have when writing xml, but that I don't care to map to my model.

In other code, when I needed to do such a thing, I created a mapping like this:

XMLTransformationMapping faultCodeLang = new XMLTransformationMapping();
faultCodeLang.addFieldTransformer("env:Code/env:Value/@xml:lang", new ConstantTransformer(Locale.getDefault()));
fault.addMapping(faultCodeLang);

this worked just fine, so this time I created a FieldTransformer that returned a random id on every buildFieldValue call and added the mapping:

XMLTransformationMapping realPropertyReferenceGmlId = new XMLTransformationMapping();
realPropertyReferenceGmlId.addFieldTransformer("building:realPropertyReference/@gml:id", new GmlIdGenerator());
building.addMapping(realPropertyReferenceGmlId);

But this time, when I unmarshal my xml I get this exception.


java.lang.NullPointerException
at org.eclipse.persistence.oxm.NamespaceResolver.put(NamespaceResolver.java:160)
at org.eclipse.persistence.internal.oxm.record.XMLTransformationRecord.initializeNamespaceMaps(XMLTransformationRecord.java:51)
at org.eclipse.persistence.internal.oxm.record.XMLTransformationRecord.(XMLTransformationRecord.java:39)

at org.eclipse.persistence.internal.oxm.FieldTransformerNodeValue.attribute(FieldTransformerNodeValue.java:82)

at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:722)
at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:132)
at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:232)

at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:133)
at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:232)
at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:133)

at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:232)
at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:133)
at org.eclipse.persistence.internal.oxm.record.DOMReader.parse(DOMReader.java:79)

at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:363)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:354)
at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:475)


Any hints of what might be going on? I have tried debugging to come up with something, but without any luck... 

NamespaceResolver:160 gets called with a null namespaceURI btw...

EclipseLink 2.1.0 (same thing in my old patched 2.0.1)...

--

 /Magnus Heino

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top