Skip to main content

Help! ContentHandlerAdaptor.startPrefixMapping called with null prefix!

1 reply [Last post]
nsayer
Offline
Joined: 2005-11-01

I'm using jwsdp-1.6 with a 1.5.0_05 JRE on Linux. I have an node in my schema I've set up with .

When attempting to marshal the JAXB root to XML, I wind up getting NPEs from the JAXB derived classes. The root cause is this stack trace:

at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:152)
at com.sun.xml.bind.unmarshaller.DOMScanner.parse(DOMScanner.java:72)
at com.netflix.core.mailerXML.impl.AuxXMLDataTypeImpl.serializeBody(AuxXMLDataTypeImpl.java:38)
at com.netflix.core.mailerXML.impl.AuxXMLDataImpl.serializeBody(AuxXMLDataImpl.java:43)
at com.netflix.core.mailerXML.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
at com.netflix.core.mailerXML.impl.EmailTypeImpl.serializeBody(EmailTypeImpl.java:708)
at com.netflix.core.mailerXML.impl.EmailImpl.serializeBody(EmailImpl.java:43)
at com.netflix.core.mailerXML.impl.runtime.SAXMarshaller.childAsBody(SAXMarshaller.java:391)
at com.netflix.core.mailerXML.impl.runtime.MarshallerImpl.write(MarshallerImpl.java:171)
at com.netflix.core.mailerXML.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:144)

At that point, impl.runtime.ContentHandlerAdaptor.startPrefixMapping is being called with a null prefix.

The root node of the DOM document does indeed have an xmlns:xxx="http://yaddayadda..." namespace declaration, but obviously 'xxx' is not null in this case.

What kills me is that if I run the exact same code on my mac, it works just fine.

If I look at the DOM document nodes before attempting to hook them up to the AuxXMLData JAXB class, they look just fine, including the namespace declaration attributes.

I would be inclined to think that this is a difference between the JAXP / DOM / SAX libraries on the two platforms, but I've tried to fetch the org.apache versions and it hasn't helped any.

I can work around the problem by editing the ContentHandlerAdaptor class and changing the null prefix into the correct one, but that would be just completely retarded.

I am slowly losing my tiny little mind. What is the deal here?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nsayer
Offline
Joined: 2005-11-01

Turns out if you are reading in an XML document with a DocumentBuilder and that document has namespaces, you need to call setNamespaceAware(true) on teh DocumentBuilderFactory. That fixed it.