dom解析器中的java.lang.StackOverflowError [英] java.lang.StackOverflowError in dom parser

查看:82
本文介绍了dom解析器中的java.lang.StackOverflowError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的应用程序中的许多线程可以访问的方法.

Following is the method that will be accessed by many threads in my application.

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;
    }

成功执行某些线程后,将出现以下错误.

After successfully executing some thread it will give following error.

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)
    .........................................................
    .........................................................

以下是成功执行线程的上层定义方法的结果

Following is the result of upper defined method for successfully executed thread

<?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文档太大,以至于试图将所有内容都整合到一个String中会导致很多方法调用,并且堆栈内存已满.尝试通过以下方式分配更多的堆栈内存:

It might simply be that your XML document is so big that trying to get it all into one String makes alot of chanined method calls and your stack memory gets full. Try allocating more stack memory via:

-Xss10m

JVM参数

(如果从Eclipse执行:右键单击项目->运行方式...->运行配置->参数选项卡-> VM参数-> -Xss1m)

(if executing from Eclipse: right click on project -> Run As... -> Run configurations -> Arguments tab -> VM Arguments -> -Xss1m)

这篇关于dom解析器中的java.lang.StackOverflowError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆