Stack traces

Java stack traces are probably familiar to even those who do not program in Java, because when something goes wrong inside a JVM application, they frequently display the raw stack trace in the output.

While the usefulness of a stack trace for a usual user is debatable, it is clear that this snippet of text contains a lot of information about the problem and helps to identify the cause. However, a raw stack trace is closer to machines than to humans, that's why we think stack trace search can help you.

What is a stack trace

When an application throws an exception, the method call hierarchy of that execution thread will be saved to the exception as an array of stack frames. The first stack frame is the current method, the last stack frame is the start of the thread (e.g., or the entry point of your application).

A Java stack trace is a textual representation of a thrown exception. While there is no standard format, it traditionally looks like this (read more in the docs):

        at com.samebug.test.Test.main(
Caused by: java.lang.NumberFormatException: For input string: "4f8:0:a102::add:9999"
        at java.lang.NumberFormatException.forInputString(
        at java.lang.Integer.parseInt(
        at java.lang.Integer.parseInt(
        ... 1 more

The important points here:

  • The stack trace starts with the fully qualified name of the exception type.
  • After the exception type, there is an optional exception message.
  • The stack frames contain the fully qualified name of the class and the method, and might contain the source location.
  • The exception might have a 'cause', a lower level exception that was wrapped in the higher level (in the above case, java.lang.NumberFormatException was wrapped in com.samebug.test.TestException).
  • The line starting with ... is part of the stack trace, it is just a shorthand to reduce the length of the output.