dom解析器中的java.lang.StackOverflower错误
下面是我的应用程序中许多线程将访问的方法dom解析器中的java.lang.StackOverflower错误,java,stack-overflow,dom4j,Java,Stack Overflow,Dom4j,下面是我的应用程序中许多线程将访问的方法 public static String getXMLAsString(org.dom4j.Document dom4jDocument) { String strXML=""; try { strXML = dom4jDocument.asXML(); } catch(Exception e){
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>
暂停^
CFS_住宅_v1
业主立案法团
{MSISDN}
真的
{username}
//ns1:updateServiceResponse
停用^
CFS_住宅_v1
业主立案法团
{MSISDN}
真的
{username}
//ns1:updateServiceResponse
激活^
CFS_住宅_v1
业主立案法团
{MSISDN}
假的
{username}
//ns1:updateServiceResponse
可能只是因为您的XML文档太大,试图将其全部放在一个字符串中会导致大量的更改方法调用,堆栈内存也会满。尝试通过以下方式分配更多堆栈内存:
-Xss10m
JVM参数
(如果从Eclipse执行:右键单击项目->运行方式…->运行配置->参数选项卡->虚拟机参数->-Xss1m)您的数据是什么样子的?它是干净且有效的xml吗?看起来像一个无限递归循环,但不知道是什么导致它…添加到Michael comment中,尝试发布您获得的示例xml作为此代码的输入,如果可能的话,发布在这里。如果dom4j允许,我会感到惊讶,但是,当元素是它自己的祖先时,您还没有创建XML文档吗?您应该尝试调试代码,以查看异常发生时堆栈跟踪的外观。如果有相同的方法调用序列重复的模式,那么看看XML解析器库正在尝试做什么可能会有所帮助。MyJBoss无法使用10m大小的堆栈,因此我设置了6m,但仍然面临相同的错误。