Back Forum Reply New

nu.xom.IllegalNameException in AbstractXomPayloadEndpoint

Hi,

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

lt;env:Envelope
xmlns:env=quot;soap/envelope/quot;
xmlns:xsi=quot;2001/XMLSchema-instancequot;
xmlns:soapenc=quot;soap/encoding/quot;
xmlns:xsd=quot;2001/XMLSchemaquot;gt;
lt;env:Bodygt;
lt;n1AYLOAD_ROOT
xmlns:n1=quot;namespacequot;gt;
lt;n1:something1
xmlns:n1=quot;namespacequot;gt;
value1
lt;/n1:something1gt;
lt;n1:something2
xmlns:n1=quot;namespacequot;gt;
value2
lt;/n1:something2gt;
lt;n1:something3
xmlns:n1=quot;namespacequot;gt;
value3
lt;/n1:something3gt;
lt;/n1AYLOAD_ROOTgt;
lt;/env:Bodygt;
lt;/env:Envelopegt;

note the declaration of the namespace (mlns:n1=quot;namespacequot; on payload root and on all elements under the payload root).

The exception stacktrace follows:

2008-04-11 17:09:33,330 DEBUG org..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.lt;initgt;(Attribute.java:168)       at nu.xom.Attribute.lt;initgt;(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..ws.server.endpoint.AbstractXom  PayloadEndpoint.handleDomSource(AbstractXomPayload  Endpoint.java:97)       at org..ws.server.endpoint.AbstractXom  PayloadEndpoint.invoke(AbstractXomPayloadEndpoint.  java:56)       at org..ws.server.endpoint.adapter.Pay  loadEndpointAdapter.invoke(PayloadEndpointAdapter.  java:48)       at org..ws.server.MessageDispatcher.di  spatch(MessageDispatcher.java:216)       at org..ws.server.MessageDispatcher.re  ceive(MessageDispatcher.java:163)       at org..ws.transport.support.WebServic  eMessageReceiverObjectSupport.handleConnection(Web  ServiceMessageReceiverObjectSupport.java:88)       at org..ws.transport.from.WebServiceMe  ssageReceiverHandlerAdapter.handle(WebServiceMessa  geReceiverHandlerAdapter.java:57)       at org..ws.transport.from.MessageDispa  tcherServlet.doService(MessageDispatcherServlet.ja  va:197)       at org..web.servlet.FrameworkServlet.p  rocessRequest(FrameworkServlet.java:476)       at org..web.servlet.FrameworkServlet.d  oPost(FrameworkServlet.java:441)       at javax.servlet.from.fromServlet.service(fromServlet  .java:710)       at javax.servlet.from.fromServlet.service(fromServlet  .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).

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:lt;env:Envelope       xmlns:env=quot;soap/envelope/quot;       xmlns:xsi=quot;2001/XMLSchema-instancequot;       xmlns:soapenc=quot;soap/encoding/quot;       xmlns:xsd=quot;2001/XMLSchemaquot;gt;       lt;env:Bodygt;    lt;n1AYLOAD_ROOT            xmlns:n1=quot;namespacequot;gt;            lt;n1:something1                    xmlns:n1=quot;namespacequot;gt;                    value1            lt;/n1:something1gt;            lt;n1:something2                    xmlns:n1=quot;namespacequot;gt;                    value2            lt;/n1:something2gt;            lt;n1:something3                    xmlns:n1=quot;namespacequot;gt;                    value3            lt;/n1:something3gt;    lt;/n1AYLOAD_ROOTgt;       lt;/env:Bodygt;lt;/env:Envelopegt;
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.lt;initgt;(Attribute.java:168)       at nu.xom.Attribute.lt;initgt;(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..ws.server.endpoint.AbstractXom  PayloadEndpoint.handleDomSource(AbstractXomPayload  Endpoint.java:97)       at org..ws.server.endpoint.AbstractXom  PayloadEndpoint.invoke(AbstractXomPayloadEndpoint.  java:56)       at org..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.

.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.  lt;initgt;(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..ws.soap.saaj.Saaj13Implementat  ion.hasFault(Saaj13Implementation.java:205)       at org..ws.soap.saaj.SaajSoapBody.hasF  ault(SaajSoapBody.java:49)       at org..ws.soap.AbstractSoapMessage.ha  sFault(AbstractSoapMessage.java:56)       at org..ws.server.MessageDispatcher.tr  iggerHandleResponse(MessageDispatcher.java:336)       at org..ws.server.MessageDispatcher.di  spatch(MessageDispatcher.java:219)       at org..ws.server.MessageDispatcher.re  ceive(MessageDispatcher.java:163)       at org..ws.transport.support.WebServic  eMessageReceiverObjectSupport.handleConnection(Web  ServiceMessageReceiverObjectSupport.java:88)       at org..ws.transport.from.WebServiceMe  ssageReceiverHandlerAdapter.handle(WebServiceMessa  geReceiverHandlerAdapter.java:57)       at org..ws.transport.from.MessageDispa  tcherServlet.doService(MessageDispatcherServlet.ja  va:197)       at org..web.servlet.FrameworkServlet.p  rocessRequest(FrameworkServlet.java:476)       at org..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.

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

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?


Originally Posted by shagaSo 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.
¥
Back Forum Reply New