2012-01-17 78 views
0

以下是將由我的應用程序中的許多線程訪問的方法。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> 
+1

你的數據看起來像什麼?它是乾淨的和有效的XML? – 2012-01-17 16:02:25

+1

看起來像一個無限遞歸循環,不知道是什麼原因... – esaj 2012-01-17 16:05:26

+0

添加到邁克爾的評論,嘗試發佈樣品xml作爲這個代碼的輸入,如果可能的話在這裏發佈。 – kosa 2012-01-17 16:06:24

回答

1

這可能只是你的XML文檔是如此之大,試圖讓這一切變成一個字符串使得chanined很多方法調用和堆棧內存變滿。嘗試通過分配更多的堆棧內存:

-Xss10m 

JVM參數

(如果從Eclipse中執行:右鍵單擊項目 - >運行方式 - >運行配置 - >參數選項卡 - > VM參數 - > -Xss1m)

+1

只要記住,它是每個線程10兆... – 2012-01-17 17:58:37

+0

Myjbosss不與堆棧大小10米工作,所以我已經設置6米,但仍然面臨同樣的錯誤。 – chetan 2012-01-19 10:01:58