Search code examples
javawebsphere

Local part cannot be "null" when creating a QName


We are trying to track down a bug. We get the above error in the logs.

Can anyone explain what this message means? Are there any typical reasons for getting this message?

The stacktrace is:

org.apache.axiom.om.OMException: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName
            at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:206)
            at org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:318)
            at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:618)
            at org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.toOM(SAAJConverterImpl.java:147)
            at org.apache.axis2.jaxws.message.impl.XMLPartImpl._convertSE2OM(XMLPartImpl.java:77)
            at org.apache.axis2.jaxws.message.impl.XMLPartBase.getContentAsOMElement(XMLPartBase.java:203)
            at org.apache.axis2.jaxws.message.impl.XMLPartBase.getAsOMElement(XMLPartBase.java:255)
            at org.apache.axis2.jaxws.message.impl.MessageImpl.getAsOMElement(MessageImpl.java:464)
            at org.apache.axis2.jaxws.message.util.MessageUtils.putMessageOnMessageContext(MessageUtils.java:202)
            at org.apache.axis2.jaxws.core.controller.AxisInvocationController.prepareRequest(AxisInvocationController.java:370)
            at org.apache.axis2.jaxws.core.controller.InvocationController.invoke(InvocationController.java:120)
            at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:317)
            at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:148)

Solution

  • I got the same error message (local part cannot be "null" when creating a QName) while trying to construct a org.w3c.dom.Document from String. The problem went away after calling setNamespaceAware(true) on DocumentBuilderFactory. Working code snippet is given below.

    private static Document getDocumentFromString(final String xmlContent)
      throws Exception
    {
        DocumentBuilderFactory documentBuilderFactory =
                                    DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);
        try
        {
            return documentBuilderFactory
                        .newDocumentBuilder()
                        .parse(new InputSource(new StringReader(xmlContent)));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }