gpt4 book ai didi

java - Node.getTextContent() 上的 AbstractMethodError

转载 作者:行者123 更新时间:2023-11-30 07:51:00 28 4
gpt4 key购买 nike

下面是抛出 AbstractMethodError 的示例代码块:

import org.w3c.dom.Node;
..
Node root = soapBody.getElementByTagNameNS("http://xxx.xxx/Schema/v9", "Result").item(0); //Namespace
for (int i = 0; i < root.getChildNodes().getLength(); i++) {
Node child = root.getChildNodes().item(i); //Set to SubResult
String result = child.getTextContent(); //Throws error
}

肥皂响应示例:

soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><a1:Response xmlns:a1="http://xxx.xxx/Schema/v9"><a1:SubResult>50</<a1:SubResult></a1:Response></soapenv:Body></soapenv:Envelope>

抛出错误:

java.lang.AbstractMethodError: org.apache.axis.message.MessageElement.getTextContent()Ljava/lang/String;

使用的Java版本:1.5

Tomcat 版本 - 6.0.41

已检查org.w3c.dom.Node for 1.5它确实有方法 getTextContent()

导致此错误的可能原因是什么?另外,为什么会出现:org.apache.axis.message.MessageElement而不是org.w3c.Node

最佳答案

javadoc of the AbstractMethodError说:

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

所以看起来你的类路径中有一些不兼容的版本。

org.apache.axis.message.MessageElement 是 Axis 的一部分,应该实现 org.w3c.dom.Node 因此这两个版本似乎不存在匹配。确保您的类路径中有两者的匹配版本。

关于java - Node.getTextContent() 上的 AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33340574/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com