简体   繁体   中英

java.lang.StackOverflowError in dom parser

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>

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 argument

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM