English 中文(简体)
null是否总是抛出在跟踪中提到的最上面一行?
原标题:Is the null always thrown on the topmost line mentioned in the trace?

我正在尝试查找此跟踪中的错误源:

org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver logException: Handler execution resulted in exception
java.lang.NullPointerException
    at com.wikistart.service.WikiServiceImpl.getWikis(WikiServiceImpl.java:548)
    at com.wikistart.controller.WikiController.wiki(WikiController.java:88)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:43)

null是否总是抛出在跟踪中提到的最上面一行?

换句话说,这个NullPointerException来自WikiServiceImpl.java:548,而不是来自WikiController.java:88

最佳回答

是的,跟踪的顶部是异常的来源。堆栈跟踪将显示每个方法的调用位置。

因此,在您的案例中,NullPointerException是在第548行的WikiServiceImpl.java中抛出的,在那里执行的方法是从第88行的WikiController.java调用的,依此类推。

问题回答

是的,它来自最上面的一行。

从那里往下的每一行都指示一个调用上面内容的方法请参阅此处以获取有关堆栈争用的更多信息。

检查出现NullPointerException的可能原因-然后应该很明显是哪个对象导致了异常。

对堆栈表示您在代码中的位置。呼叫从底部开始,然后向上工作。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...