wiki
wiki

Reputation: 3439

Is the null always thrown on the topmost line mentioned in the trace?

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?

Upvotes: 1

Views: 136

Answers (3)

Preet Sangha
Preet Sangha

Reputation: 65516

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

Upvotes: 0

Alan Geleynse
Alan Geleynse

Reputation: 25139

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.

Upvotes: 6

Bozho
Bozho

Reputation: 597234

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.

Upvotes: 4

Related Questions