Announcement Announcement Module
Collapse
No announcement yet.
nu.xom.IllegalNameException in AbstractXomPayloadEndpoint Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • nu.xom.IllegalNameException in AbstractXomPayloadEndpoint

    Hi,

    I experience the following exception when dealing with specifically formated XML. The soap message looks like this:

    <env:Envelope
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <env:Body>
    <n1:PAYLOAD_ROOT
    xmlns:n1="http://www.company.com/namespace">
    <n1:something1
    xmlns:n1="http://www.company.com/namespace">
    value1
    </n1:something1>
    <n1:something2
    xmlns:n1="http://www.company.com/namespace">
    value2
    </n1:something2>
    <n1:something3
    xmlns:n1="http://www.company.com/namespace">
    value3
    </n1:something3>
    </n1:PAYLOAD_ROOT>
    </env:Body>
    </env:Envelope>

    note the declaration of the namespace (mlns:n1="http://www.company.com/namespace" on payload root and on all elements under the payload root).

    The exception stacktrace follows:

    2008-04-11 17:09:33,330 DEBUG org.springframework.ws.soap.server.SoapMessageDisp atcher - Endpoint invocation resulted in exception - responding with Fault
    nu.xom.IllegalNameException: Attribute objects are not used to represent namespace declarations
    at nu.xom.Attribute._setNamespace(Attribute.java:489)
    at nu.xom.Attribute.<init>(Attribute.java:168)
    at nu.xom.Attribute.<init>(Attribute.java:122)
    at nu.xom.converters.DOMConverter.makeElement(DOMConv erter.java:388)
    at nu.xom.converters.DOMConverter.convert(DOMConverte r.java:349)
    at org.springframework.ws.server.endpoint.AbstractXom PayloadEndpoint.handleDomSource(AbstractXomPayload Endpoint.java:97)
    at org.springframework.ws.server.endpoint.AbstractXom PayloadEndpoint.invoke(AbstractXomPayloadEndpoint. java:56)
    at org.springframework.ws.server.endpoint.adapter.Pay loadEndpointAdapter.invoke(PayloadEndpointAdapter. java:48)
    at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:216)
    at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:163)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:88)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:197)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:476)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:441)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
    etc.

    Spring-WS is 1.5, Java 1.6, xom as provided by maven dependencies. Thanks for help (even sending me to XOM mailinglist, if it is XOM bug).

  • #2
    from the XOM mailing list

    I posted a question into the XOM mailing list:

    Hello all,

    I use XOM in Spring-WS as the DOM of choice. I run into an exception mentioned in the subject. The offending XML looks like this:

    <env:Envelope
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <env:Body>
    <n1:PAYLOAD_ROOT
    xmlns:n1="http://www.company.com/namespace">
    <n1:something1
    xmlns:n1="http://www.company.com/namespace">
    value1
    </n1:something1>
    <n1:something2
    xmlns:n1="http://www.company.com/namespace">
    value2
    </n1:something2>
    <n1:something3
    xmlns:n1="http://www.company.com/namespace">
    value3
    </n1:something3>
    </n1:PAYLOAD_ROOT>
    </env:Body>
    </env:Envelope>

    And the stacktrace like this:

    nu.xom.IllegalNameException: Attribute objects are not used to
    represent namespace declarations
    at nu.xom.Attribute._setNamespace(Attribute.java:489)
    at nu.xom.Attribute.<init>(Attribute.java:168)
    at nu.xom.Attribute.<init>(Attribute.java:122)
    at nu.xom.converters.DOMConverter.makeElement(DOMConv erter.java:388)
    at nu.xom.converters.DOMConverter.convert(DOMConverte r.java:349)
    at org.springframework.ws.server.endpoint.AbstractXom PayloadEndpoint.handleDomSource(AbstractXomPayload Endpoint.java:97)
    at org.springframework.ws.server.endpoint.AbstractXom PayloadEndpoint.invoke(AbstractXomPayloadEndpoint. java:56)
    at org.springframework.ws.server.endpoint.adapter.Pay loadEndpointAdapter.invoke(PayloadEndpointAdapter. java:48)
    ...etc...

    AbstractXomPayloadEndpoint. is trying to create the Document object from the payload part of the document - with PAYLOAD_ROOT as the root element of the Document.

    The problem with the XML document is the redefinition of the namespace in the payload root subelements. That is the thing that triggers the exception.

    Is it XOM bug or spring's incorrect XOM usage?

    All run on Java 1.6 and XOM 1.1.

    I got this reply:

    Sounds like it's either latter, or that DOM document itself was built in non-namespace-aware mode. If it's latter, you need to ensure that DOM is built to be aware of namespaces: JAXP default is non-namespace aware, so it's a common problem.

    Maybe it will help.

    Comment


    • #3
      OK, another problem, now with JDom

      I tried to switch from XOM to JDom. The problem is not triggered when JDom is used, but I run into another problem...

      import org.jdom.Document;
      import org.jdom.Element;
      import org.jdom.output.XMLOutputter;

      protected Element invokeInternal(final Element root) throws Exception {
      ...
      logElement(toRet);
      return toRet;
      }

      private void logElement(Element el) {
      Document doc = new Document();
      doc.setRootElement(el);
      XMLOutputter outputer = new XMLOutputter();
      log.debug("Document: " + outputer.outputString(doc));
      }

      log returns (minus formatting):

      <Response xmlns="http://www.company.com">
      <Wrapper>
      <errorCategory>BAD_REQUEST</errorCategory>
      <errorCode>601</errorCode>
      <errorDescription>etc. etc.</errorDescription>
      <element1>xxx</element1>
      <element2>yyy</element2>
      </Wrapper>
      </Response>

      and the service fails with:

      2008-04-14 15:03:01,721 DEBUG org.springframework.ws.soap.server.SoapMessageDisp atcher - Endpoint invocation resulted in exception - responding with Fault
      org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
      at com.sun.org.apache.xerces.internal.dom.CoreDocumen tImpl.checkNamespaceWF(CoreDocumentImpl.java:2503)
      at com.sun.org.apache.xerces.internal.dom.AttrNSImpl. setName(AttrNSImpl.java:89)
      at com.sun.org.apache.xerces.internal.dom.AttrNSImpl. <init>(AttrNSImpl.java:74)
      at com.sun.org.apache.xerces.internal.dom.CoreDocumen tImpl.createAttributeNS(CoreDocumentImpl.java:2127 )
      at com.sun.xml.internal.messaging.saaj.soap.SOAPDocum entImpl.createAttributeNS(SOAPDocumentImpl.java:16 1)
      at com.sun.org.apache.xerces.internal.dom.ElementImpl .setAttributeNS(ElementImpl.java:656)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl.setAttributeNS(ElementImpl.java:1213)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl.addAttributeBare(ElementImpl.java:491)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl.addAttributeBare(ElementImpl.java:463)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl.replaceElementWithSOAPElement(ElementImpl. java:657)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Body Impl.convertToSoapElement(BodyImpl.java:256)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl$5.next(ElementImpl.java:1109)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Elem entImpl$2.hasNext(ElementImpl.java:683)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Body Impl.findFault(BodyImpl.java:132)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Body Impl.initializeFault(BodyImpl.java:126)
      at com.sun.xml.internal.messaging.saaj.soap.impl.Body Impl.hasFault(BodyImpl.java:143)
      at org.springframework.ws.soap.saaj.Saaj13Implementat ion.hasFault(Saaj13Implementation.java:205)
      at org.springframework.ws.soap.saaj.SaajSoapBody.hasF ault(SaajSoapBody.java:49)
      at org.springframework.ws.soap.AbstractSoapMessage.ha sFault(AbstractSoapMessage.java:56)
      at org.springframework.ws.server.MessageDispatcher.tr iggerHandleResponse(MessageDispatcher.java:336)
      at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:219)
      at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:163)
      at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:88)
      at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
      at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:197)
      at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:476)
      at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:441)
      ...etc...

      It's out of my reach and code. Configuration as above: java 6, tomcat 6, spring-ws 1.5.

      Thanks again for any help.

      Comment


      • #4
        Make sure you use a recent version of Xalan (2.7.0 works for me).

        Comment


        • #5
          Hi, thanks for the tip.

          I managed to get rid of the exceptions mentioned above bz using DOM4J. The trouble with recent version of xalan is that I don't have dependency on xalan, I removed it explicitly, because I use Java 6 and I was having issues with class cast exceptions and such (actually we discussed it here and removing this dependency was your hint - and it really helped).

          So I still consider it a bug. Should I create a small project and upload it somewhere to demonstrate it?

          Comment


          • #6
            Originally posted by shaga View Post
            So I still consider it a bug. Should I create a small project and upload it somewhere to demonstrate it?
            That would be great. You can create a JIRA issue, and attach the project to it.

            Comment

            Working...
            X