Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stack overflow exception on xml transformation

I am getting the following java stackoverflow error on a xml transformation in weblogic server 10g hosted in sun solaris. This happens only for a particular xml tranformation and rest all xml transformation works fine. The xsl file used is also not very big.

I am using the Transformation api available in rt.jar but getting this error from xalan apache package(com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl) which I havent packaged in my application.

Another interesting thing is that I didnt get this exception when I run the application in weblogic 10g server hosted in windows machine, I get this only in sun solaris.

Can anyone let me know why I get this error.

Can you let me know which jar file is causing the exception ? Will weblogic have a xalan.jar ? If so I can try to upgrade the jar file and see if its working ?

Caused by: java.lang.StackOverflowError
    at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters(SimpleResultTreeImpl.java)
    at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.copy(SimpleResultTreeImpl.java:438)
    at com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.copy(BasisLibrary.java:1317)
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
    at GregorSamsa.replace()
like image 328
Ashok Ambrose Avatar asked Oct 08 '22 15:10

Ashok Ambrose


1 Answers

It appears that there is some recursion happening here based on all the calls to GregorSamsa.replace(). The fact that it works on Windows and not Solaris could be due to different implementations of the JVM or more likely, default JVM options for stack size.

Here is what the JVM stack size option does.

Here is how you can increase the stack size in Eclipse.

Here is how you can set the stack size via command line along with more discussion on this topic:

$ javac TT.java
$ java -Xss4m TT

-Xss4m = 4 megs
-Xss1024k = 1024kb

If you want to launch a new thread from your application with a specified stack size for only that thread then take a look at the constructors for Thread class, including:

public Thread(ThreadGroup group, Runnable target,String name,long stackSize)
like image 172
Michael Freake Avatar answered Oct 10 '22 07:10

Michael Freake