-2
在jboss 4中,我们使用了dom4j SAX解析器来读取server.xml。它工作正常,但它不是在JBoss的EAP 6。下面的情况下,工作在JBoss的4更改JBoss EAP 6端口号
public static Document modifyAttributeValue(Document document, String elementName, String attributeName, String attributeValue) {
if (document == null)
return document;
try {
Element element = (Element) document.selectSingleNode(elementName);
if (element != null) {
Attribute attribute = element.attribute(attributeName);
attribute.setValue(attributeValue);
}
} catch (Exception e) {
logger.error("Failed to modify attribute.", e);
}
return document;
}
我得到元素作为空值使用的代码。
因此,无论您尝试选择哪个元素都不在该文件中,并且可能已移至其他文件。通过实际执行研究来修复它。 – Gimby
我正在使用此代码获取节点 – Rajesh
modifyAttributeValue(document,“// socketbinding [@ name ='http']”,“port”,“8080”); – Rajesh