When running my application, after 40000 transactions getting stack overflow exception at java.util.Properties.getProperty.
Please find below the stack error ..
java.lang.StackOverflowError
at java.util.Hashtable.get(Hashtable.java:334)
at java.util.Properties.getProperty(Properties.java:932)
at java.util.Properties.getProperty(Properties.java:934)
... 80,0000 times
at java.util.Properties.getProperty(Properties.java:934)
at java.lang.System.getProperty(System.java:653)
at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:67)
at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:32)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.PrintWriter.<init>(PrintWriter.java:78)
at java.io.PrintWriter.<init>(PrintWriter.java:62)
at java.util.logging.SimpleFormatter.format(SimpleFormatter.java:71)
at org.apache.juli.FileHandler.publish(FileHandler.java:133)
at java.util.logging.Logger.log(Logger.java:481)
at java.util.logging.Logger.doLog(Logger.java:503)
at java.util.logging.Logger.logp(Logger.java:703)
at org.apache.commons.logging.impl.Jdk14Logger.log(Jdk14Logger.java:101)
at org.apache.commons.logging.impl.Jdk14Logger.error(Jdk14Logger.java:149)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:253)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:662)
I'm not able to trace the from where the stack error is thrown.
Don't mean to state the obvious, but maybe you should check if you are creating variables inside the loop that performs these transactions (the 40.000 repetitions one :-)), instead of reusing the same variable. Also, checking the constraint inside the loop can create unnecessary load. String concatenation can produce massive load, too. So, if you have something like this:
for (i=0; i < getNumberOfTransactions(); i++){ // constraint checking inside the loop
int currentValue = myTransaction.getSomeData(); // creating new variable in every
}
You should write something like this instead:
int numberOfTransactions = getNumberOfTransactions();
int currentValue = 0;
for(i=0; i < numberOfTransactions; i++){
currentValue = myTransaction.getSomeData();
}
Although this example uses only 2 integer variables, when multiple variables are created inside the loop (especially string concatenation), this can consume a lot of memory. If you have some string concatenation, use StringBuilder class instead.