Document.adoptNode()上的ArrayIndexOutOfBoundsException

时间:2016-02-25 19:12:52

标签: java xml document

当我从文档中调用ArrayIndexOutOfBoundsException时,我收到了adoptNode()。 问题发生在第10次调用方法。

错误发生在

nodeToPutSignature.getOwnerDocument().adoptNode(signature);

所有方法代码:

Document tempDocument = new XmlParser().getDocument();
// Sign the temporary Document using xmldsig
sign(tempDocument, getAddress());
tempDocument = XmlTools.newDocument(XmlTools.nodeToString(tempDocument));
// Signature tag from temporary document
final Node signature = XmlTools.getNode(tempDocument, getAddress() + "//Signature");
final Node nodeToPutSignature = XmlTools.getNode(node, 
                                            XPathTools.getXPath(signature.getParentNode()));
// Put the signature tag on the document
nodeToPutSignature.getOwnerDocument().adoptNode(signature);
nodeToPutSignature.appendChild(signature);

所有堆栈跟踪:

java.lang.ArrayIndexOutOfBoundsException: 35
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.clearChunkIndex(DeferredDocumentImpl.java:2023)
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.getLastChild(DeferredDocumentImpl.java:826)
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.getLastChild(DeferredDocumentImpl.java:811)
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.synchronizeChildren(DeferredDocumentImpl.java:1693)
    at com.sun.org.apache.xerces.internal.dom.DeferredAttrImpl.synchronizeChildren(DeferredAttrImpl.java:142)
    at com.sun.org.apache.xerces.internal.dom.AttrImpl.setOwnerDocument(AttrImpl.java:198)
    at com.sun.org.apache.xerces.internal.dom.NamedNodeMapImpl.setOwnerDocument(NamedNodeMapImpl.java:405)
    at com.sun.org.apache.xerces.internal.dom.ElementImpl.setOwnerDocument(ElementImpl.java:235)
    at com.sun.org.apache.xerces.internal.dom.ParentNode.setOwnerDocument(ParentNode.java:184)
    at com.sun.org.apache.xerces.internal.dom.ElementImpl.setOwnerDocument(ElementImpl.java:233)
    at com.sun.org.apache.xerces.internal.dom.ParentNode.setOwnerDocument(ParentNode.java:184)
    at com.sun.org.apache.xerces.internal.dom.ElementImpl.setOwnerDocument(ElementImpl.java:233)
    at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.adoptNode(CoreDocumentImpl.java:1874)
    at br.gov.serpro.testtool.xml.testtool.tag.Sign.visit(Sign.java:67)

0 个答案:

没有答案