How to show full stack trace on eclipse?
I'm using Eclipse to debug a Java application. Somewhere in the code I get an exception and the stack trace:
Caused by: java.io.EOFException: The connection has been reset while reading the header
at com.gemstone.gemfire.internal.cache.tier.sockets.Message.fetchHeader(Message.java:583)
at com.gemstone.gemfire.internal.cache.tier.sockets.Message.readHeaderAndPayload(Message.java:599)
at com.gemstone.gemfire.internal.cache.tier.sockets.Message.read(Message.java:542)
at com.gemstone.gemfire.internal.cache.tier.sockets.Message.recv(Message.java:1029)
at com.gemstone.gemfire.cache.client.internal.AbstractOp.attemptReadResponse(AbstractOp.java:158)
at com.gemstone.gemfire.cache.client.internal.AbstractOp.attempt(AbstractOp.java:363)
at com.gemstone.gemfire.cache.client.internal.ConnectionImpl.execute(ConnectionImpl.java:229)
at com.gemstone.gemfire.cache.client.internal.pooling.PooledConnection.execute(PooledConnection.java:321)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.executeWithPossibleReAuthentication(OpExecutorImpl.java:646)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:108)
... 11 more
How do I get the whole stack instead of the ... 11 more
?
Solution 1:
You have the entire stack.
This is only part of a stack trace. Directly before this was another piece. Look at the bottom lines of this one, and the top lines of the previous one. You'll see them match up. The stack trace began with a section that doesn't begin with "Caused by".
The "Caused by" exception is hiding parts of the stack trace that are verbatim copies of stack trace entries in its parent. In other words, Java doesn't show the entire stack up to main() for every cause - it just shows what you haven't seen already. See the Throwable.printStackTrace() documentation.
The "Caused by" is filled when you provide a cause when creating a Throwable. Look at the constructors for it. This is done when a piece of code catches a low-level exception and then wants to rethrow it as a different exception class.
Solution 2:
the answers above are not accurate, every time the stack show the words "caused by" it means that the exception went through one or multiple methods until it was caught, and then thrown again. This could happen many many many times, the stack trace is not a loop, it is a single direction, so no, the stuff at the top does not relate to the stuff at the bottom, the most important part IS at the bottom, that is the root of the exception, so if you would have:
Exception in class main: blah blah blah ...lines of code... caused by FileNotFoundException ...lines of code... caused by: MalformedURLException ...lines of code... caused by: NullPointerException
then you would not want to focus so much on the FileNotFoundException, but you would want to focus more on the NullPointerException. Like say you had a properties file with a file name in it. If accidentally used mykey, to find the property "myKey", then the propertiesResource would return a null, that would then get thrown all the way through all the lines of code (hopefully) to your application where the last catch block is. . . wich, at this piont, it would be "wrapped" not as a nullException, but as a FileNotFoundException. . .
Solution 3:
We might be diverging from the actual problem he's facing. I was having similar problem and it turns out I had my Limit console out put box check marked. After I removed it I was able to see the full stack trace. Steps: Right click on console || ctrl + click if mac go to preferences and follow the above instructions
Solution 4:
I think it means that the Exception
was caught and packaged into another 11 times before printStackTrace
was called.
Try and figure out the output of the following program for better understanding:
public class PrintStackTrace {
public static void main(String[] args) {
try {
level1();
} catch (Exception e) {
e.printStackTrace();
}
try {
level2();
} catch (Exception e) {
e.printStackTrace();
}
}
static void level2() throws Exception {
try {
level1();
} catch (Exception e) {
throw new Exception(e);
}
}
static void level1() throws Exception {
try {
throwingMethod();
} catch (Exception e) {
throw new Exception(e);
}
}
static void throwingMethod() throws Exception {
throw new Exception("throwingMethod");
}
}