-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