How to read and understand java stack trace?

For example, I got a stack trace as follows:

java.lang.NullPointerException abc.investxa.presentation.controllers.UnixServerJobController.handleRequest(UnixServerJobController.java:66) org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 

So what is the main reason for this exception? From the stack trace, I found that there is a problem with the doFilter function in the OncePerRequestFilter class! However, when I put a breakpoint there, and the program never stops at that breakpoint.

Can anyone explain this ?? And in the general case, how should I use this stack case for debugging (read from bottom to top or top to bottom)!

+57
java debugging stack-trace exception
Oct 02
source share
4 answers

Typically, the exact reason for the Exception is on the first line of your Stack Trace, and for more information about the reason for this exception, you need to gradually move down, and the main reason can often be found somewhere near the bottom of the stack trace.

But in most cases, you can even get the reason for the exception from the first few lines.

So, in this case, your exception is in the handleRequest method, and when you move down, these are the methods that call your previous method (the one that is above the current method in the stack trace)

+38
Oct 02
source share

Usually you should read from above - so in this case there is a NullPointerException on line 66 of UnixServerJobController in the handleRequest method. This method was called by SimpleControllerHandlerAdapter.handle , which was called by DispatcherServlet.doDispatch , etc.

However, in this particular case, it is likely that the first frame of the stack trace is all you need. Look at line 66 from the UnixServerJobController , determine what can be null, and act accordingly.

Note that sometimes one exception is wrapped in another (which, in turn, can be wrapped in another, etc.). In this case, you should look at each stack trace - often this is the "most nested" exception that gives the most useful information, as well as the root cause.

+67
Oct 02
source share

This tutorial can shed light on your problem and help you better understand the situation.

According to your problem, you seem to have a Null Pointer exception on line 66 of the Unix Server Job Controller class.

+7
Oct 02
source share
+3
Jul 03 '13 at 3:04 on
source share



All Articles