I'm trying to locate the source of the error in this 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.r开发者_StackOverflow社区eflect.Method.invoke(Method.java:43)
Is the null always thrown on the topmost line mentioned in the trace?
In other words, this NullPointerException
is coming from WikiServiceImpl.java:548
and not from WikiController.java:88
?
Yes the top of the trace is where the exception is coming from. The stack trace is showing you where each method was called from.
So in your case, the NullPointerException was thrown in WikiServiceImpl.java on line 548, and the method that was executing there was called from WikiController.java line 88, and so on.
Yes, it is coming from the topmost line.
From there each line down indicates a method that calls the above. See here for more information about stacktraces.
Check the possible reasons for a NullPointerException
- it should then be obvious which object causes the exception.
Yes. The Stack represents where you were in you were in the code. The call starts are the bottom and works upwards.
精彩评论