本文介绍了如何阅读和理解 java 堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我得到了这样的堆栈跟踪:

For example, I got a stack trace like this:

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)

那么这个异常的根本原因是什么?从堆栈跟踪中,我发现 OncePerRequestFilter 类中的 doFilter 函数存在问题!但是,当我在那里设置断点时,程序永远不会在该断点处停止.

So what is the root cause of this exception?From the stack trace, I found out that there is a problem with doFilter function in the OncePerRequestFilter class! However, when I put a break point there and the program never stop at that break point.

谁能解释一下这个!?在一般情况下,我应该如何使用该堆栈案例进行调试(从下到上或从上到下阅读)!

Could anyone give explanation about this!?And in general case, how should I use that stack case for debugging (read from bottom to top or from top to bottom)!

推荐答案

通常 Exception 的确切原因在 Stack Trace 的第一行,有关原因的更多信息例外,你需要逐渐向下移动,而根本原因通常可以在堆栈跟踪底部附近的某个地方找到.

Generally the exact reason for the Exception is at the first line of your Stack Trace, and for more information about the cause of that exception, you need to gradually move down, and the root cause can often be found somewhere near the bottom of the stack trace.

但在大多数情况下,你甚至可以从前几行得到异常的原因..

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

因此,在这种情况下,您的异常位于 handleRequest 方法,当您向下移动时,这些方法会调用您以前的方法(堆栈跟踪中当前方法上方的方法))

So, in this case, your exception is at handleRequest method, and when you move downwards, those are the methods, which invoked your previous method (The one at above the current method in stack trace)

这篇关于如何阅读和理解 java 堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-20 12:33