views:

49

answers:

3

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.reflect.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?

+4  A: 

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.

Bozho
That's a difficult question. Especially as a sufficient answer is shorter that the 15 char answer length limit :)
extraneon
agreed. That's why I tried to provide some extra information.
Bozho
+6  A: 

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.

Alan Geleynse
A: 

Yes. The Stack represents where you were in you were in the code. The call starts are the bottom and works upwards.

Preet Sangha