以下是將由我的應用程序中的許多線程訪問的方法。dom解析器中的java.lang.StackOverflowError
public static String getXMLAsString(org.dom4j.Document dom4jDocument)
{
String strXML="";
try {
strXML = dom4jDocument.asXML();
}
catch(Exception e){
e.printStackTrace();
System.out.println("XMLUtility : General Exception :- "+e.getMessage());
}
return strXML;
}
成功執行某個線程後,會出現以下錯誤。
java.lang.StackOverflowError
at java.lang.String.indexOf(String.java:1352)
at org.apache.xerces.dom.ElementNSImpl.getPrefix(Unknown Source)
at org.dom4j.io.DOMReader.readElement(DOMReader.java:169)
.........................................................
.........................................................
以下是上定義的方法的成功執行線程結果
<?xml version="1.0" encoding="UTF-8"?>
<action_script>
<command>SUSPEND^
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spi="http://nsn.com/npm/SoapProvisioningInterface/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<spi:updateService>
<spi:request>
<spi:service>
<spi:serviceIdentifier>
<spi:serviceCode>CFS_Residential_v1</spi:serviceCode>
</spi:serviceIdentifier>
<spi:attributes>
<spi:attribute spi:name="CallingSystem" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">OCS</spi:value>
</spi:attribute>
<spi:attribute spi:name="MSISDN" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{MSISDN}</spi:value>
</spi:attribute>
<spi:attribute spi:name="HSSUserAdminBlock" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:boolean">true</spi:value>
</spi:attribute>
<spi:attribute spi:name="IMSPrivateID" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{username}</spi:value>
</spi:attribute>
</spi:attributes>
</spi:service>
</spi:request>
</spi:updateService>
</soapenv:Body>
</soapenv:Envelope>
</command>
<success_message>//ns1:updateServiceResponse</success_message>
<command>DEACTIVATE^
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spi="http://nsn.com/npm/SoapProvisioningInterface/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<spi:updateService>
<spi:request>
<spi:service>
<spi:serviceIdentifier>
<spi:serviceCode>CFS_Residential_v1</spi:serviceCode>
</spi:serviceIdentifier>
<spi:attributes>
<spi:attribute spi:name="CallingSystem" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">OCS</spi:value>
</spi:attribute>
<spi:attribute spi:name="MSISDN" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{MSISDN}</spi:value>
</spi:attribute>
<spi:attribute spi:name="HSSUserAdminBlock" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:boolean">true</spi:value>
</spi:attribute>
<spi:attribute spi:name="IMSPrivateID" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{username}</spi:value>
</spi:attribute>
</spi:attributes>
</spi:service>
</spi:request>
</spi:updateService>
</soapenv:Body>
</soapenv:Envelope>
</command>
<success_message>//ns1:updateServiceResponse</success_message>
<command>ACTIVATE^
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spi="http://nsn.com/npm/SoapProvisioningInterface/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<spi:updateService>
<spi:request>
<spi:service>
<spi:serviceIdentifier>
<spi:serviceCode>CFS_Residential_v1</spi:serviceCode>
</spi:serviceIdentifier>
<spi:attributes>
<spi:attribute spi:name="CallingSystem" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">OCS</spi:value>
</spi:attribute>
<spi:attribute spi:name="MSISDN" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{MSISDN}</spi:value>
</spi:attribute>
<spi:attribute spi:name="HSSUserAdminBlock" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:boolean">false</spi:value>
</spi:attribute>
<spi:attribute spi:name="IMSPrivateID" xsi:type="spi:singlevalue">
<spi:value xsi:type="xsd:string">{username}</spi:value>
</spi:attribute>
</spi:attributes>
</spi:service>
</spi:request>
</spi:updateService>
</soapenv:Body>
</soapenv:Envelope>
</command>
<success_message>//ns1:updateServiceResponse</success_message>
</action_script>
你的數據看起來像什麼?它是乾淨的和有效的XML? – 2012-01-17 16:02:25
看起來像一個無限遞歸循環,不知道是什麼原因... – esaj 2012-01-17 16:05:26
添加到邁克爾的評論,嘗試發佈樣品xml作爲這個代碼的輸入,如果可能的話在這裏發佈。 – kosa 2012-01-17 16:06:24