[ http://issues.apache.org/jira/browse/AXIS-2347?page=comments#action_12360891 ]
Jayachandra Sekhara Rao Sunkara commented on AXIS-2347: ------------------------------------------------------- When I delved inside the source, I realized that the problem is cropping up because of logic inside NodeImpl.setParent(...) method. Here is the explanation and a suggested patch. ******* The current NodeImpl.setParent() code looks like follows... ln 1 /** ln 2 * Set the parent node and invoke appendChild(this) to ln 3 * add this node to the parent's list of children. ln 4 * @param parent ln 5 * @throws SOAPException ln 6 */ ln 7 protected void setParent(NodeImpl parent) throws SOAPException { ln 8 if (this.parent == parent) { ln 9 return; ln 10 } ln 11 if (this.parent != null) { ln 12 this.parent.removeChild(this); ln 13 } ln 14 if (parent != null) { ln 15 parent.appendChild(this); ln 16 } ln 17 this.setDirty(); ln 18 this.parent = parent; ln 19 } There is a sly bug in this code. At line 12 <code>this</code> (lets denote it as NODE_C) node is removed as a child from its existing parent (lets call this parent as NODE_P) but the link of NODE_C.parent still points to NODE_P. Because of this later when <code>appendChild</code> method is called at ln15 with NODE_C sent as the parameter, within the code of appendChild since there is going to be a detachNode call on NODE_C that call is going to fail as NODE_C claims it has a non-null parent (NODE_P) but NODE_P list of children list doesn't contain NODE_C. So I'm suggesting the following patch ln 11 if (this.parent != null) { ln 12 this.parent.removeChild(this); ln 12a this.parent = null; //remove all old lineage traces from both sides ln 12b //so that future appendChild()/detachNode() doesn't crib ln 13 } ********* I've tested the patch and found that it doesn't break any existing scenarios. I'll check this in EOD today unless someone has any objection. > setBody results in a DOMException > --------------------------------- > > Key: AXIS-2347 > URL: http://issues.apache.org/jira/browse/AXIS-2347 > Project: Apache Axis > Type: Bug > Components: SAAJ > Versions: 1.3 > Reporter: Jayachandra Sekhara Rao Sunkara > Assignee: Jayachandra Sekhara Rao Sunkara > Attachments: TestSOAPEnvelope.java > > The act of detaching the body of a soap envelope and trying to set its body > with a new soap body results in following Exception > javax.xml.soap.SOAPException: javax.xml.soap.SOAPException: > org.w3c.dom.DOMExcep > tion: NodeImpl Not found > at org.apache.axis.message.SOAPBody.setParentElement(SOAPBody.java > :91) > at org.apache.axis.message.SOAPEnvelope.setBody(SOAPEnvelope.java:309) > at > mytest.soapenvelope.TestSOAPEnvelope.setBody(TestSOAPEnvelope.java:16 > ) > at mytest.soapenvelope.TestSOAPEnvelope.main > (TestSOAPEnvelope.java:40) > Caused by: javax.xml.soap.SOAPException: org.w3c.dom.DOMException: NodeImpl > Not > found > at > org.apache.axis.message.NodeImpl.setParentElement(NodeImpl.java:634) > at org.apache.axis.message.SOAPBody.setParentElement > (SOAPBody.java:88) > ... 3 more > Caused by: org.w3c.dom.DOMException: NodeImpl Not found > at org.apache.axis.message.NodeImpl.removeChild(NodeImpl.java:515) > at org.apache.axis.message.SOAPEnvelope.removeChild > (SOAPEnvelope.java:61 > 7) > at org.apache.axis.message.NodeImpl.detachNode(NodeImpl.java:661) > at org.apache.axis.message.NodeImpl.appendChild(NodeImpl.java:493) > at org.apache.axis.message.NodeImpl.setParent (NodeImpl.java:792) > at > org.apache.axis.message.NodeImpl.setParentElement(NodeImpl.java:632) > ... 4 more > Attached test case (TestSOAPEnvelope.java) describes the scenario. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira