How to stop the stack of stacks in magazines

How many times in Java logs do I get something like:

Caused by: java.sql.BatchUpdateException: failed batch at org.hsqldb.jdbc.jdbcStatement.executeBatch(jdbcStatement.java:1102) at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(jdbcPreparedStatement.java:514) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242) ... 113 more 

Does anyone know how to get a complete stacktrace indication (i.e. show the remaining 113 lines)?




JavaDocs (for Java 7) for Throwable have a fairly detailed explanation of what is happening.

+66
java stack-trace exception
Jan 13 '09 at 2:12
source share
4 answers

When you see "... 113 more," this means that the other lines of the exception are "called" identical to the rest of the lines from this point of the parent exception.

For example, you will have

 com.something.XyzException at ... at ... at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242) at ... <the other 113 lines are here>... Caused by: <the above>. 

Two stack traces are found in AbstractBatcher.executeBatch, line 242, and then followed by upward tracing - this is the same as a shell exception.

+65
Jan 13 '09 at 2:20
source share

Apache Commons Lang provides a good utility method called ExceptionUtils.printRootCauseStackTrace () , which prints the nested stop table upside down. The result is much intuitive.

If you see the result next to the original from the printStackTrace () method, it will be clear where the 113 more lines go.

+19
Jan 13 '09 at 9:41
source share

I like the example here :

 HighLevelException: MidLevelException: LowLevelException at Junk.a(Junk.java:13) at Junk.main(Junk.java:4) Caused by: MidLevelException: LowLevelException at Junk.c(Junk.java:23) at Junk.b(Junk.java:17) at Junk.a(Junk.java:11) ... 1 more Caused by: LowLevelException at Junk.e(Junk.java:30) at Junk.d(Junk.java:27) at Junk.c(Junk.java:21) ... 3 more 

Basically in the source code, main calls function a , which calls function b , which calls ... which calls function e . function e throws a LowLevelException , which is why function c catches a LowLevelException and throws a MidLevelException (terminates the LowLevelException inside the MidLevelException ). The Exception class has a constructor capable of taking in another exception, wrapping it). This calls a function to catch a MidLevelException and throw a HighLevelException , which now wraps the previous two Exception instances.

As noted in other answers, the stack trace is not actually truncated, you see the full stack trace. .. .3 more in my example, because otherwise it will be superfluous. If you want to be redundant and output output lines, .. 3 more can be replaced by

 at Junk.b(Junk.java:17) at Junk.a(Junk.java:11) at Junk.main(Junk.java:4) 

But there is no need to print these three lines, because they are already implied.

+10
Dec 20 '14 at 2:09
source share

In a blog post, I just described how to get more than just “BatchUpdateException: failed batch” : set hibernate.jdbc.factory_class=org.hibernate.jdbc.NonBatchingBatcherFactory to disable batch processing in sleep mode. You can usually use BatchUpdateException.getNextException to get the reason for the failure, but in some cases it may return null . Then it is useful to completely disable dosing.

-one
Nov 18 '12 at 23:26
source share



All Articles