cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

java.lang.NullPointerException

Former Member
0 Likes
2,912

Hi All,

Can Any one tell me abt java.lang.NullPointerException.

when we will get this type of error and how to solve this.

if we get this error where we have to check the error.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Likes

thanks to every one.!

Former Member
0 Likes

Hi there,

Null pointer exception is normally gotten when you forgot to initialise a variable. Even for object itself, it could be pointing to no where because you did not initialise any valid object to it. Eg, the Ball object has a Color attribute, but because you did not set anything for it and when you TRY to use getColor, it will throw a null pointer exception because it got nothing, not even a "" (space) is set.

Former Member
0 Likes
Former Member
0 Likes

Hi Sreelakshmi,

You get a Null Pointer Exception, when you are trying to use (not just read , but use) an object which has null value ( eg: when you try to invoke a function on a null object). It is something like, there is no object created on the heap, but still you are trying to invoke a method using this non-existent object.

Below are some ways of seeing the details of this exception:

1. Wrap your code in a try- catch block. In the catch block write the code :

try{......[code]....... }

catch(Exception e) {

e.printStackTrace();

wdComponentAPI.getMessageManager().reportException(e.getMessage());

}

This will display the exception on the screen.

2. If you are unable to see the exception, then go to:

http://[server-name]:[port-no]/nwa -> Problem Management -> Logs and Traces -> Log Viewer -> Show: General View and Select View as "Default Trace (Java)".

Hope this helps.

Regards,

Gaurav.

Edited by: Gaurav Narkar on May 14, 2009 9:39 AM

Former Member
0 Likes

Hi

U will receive NullPointerException when u r trying to address a parameter that holds null value.

For instance if u try to get the value of a context attribute and that value is null u will receive that exception.

In order to understand why does it happen u will have to examine when in the application is it being throwed ( like : when clicking a specific button ) .

And then debug the code of the event to understand when do u point null.

If u will send the complete exception thrown I can tell u at which method it was thrown.

Hope it helps

Nitsan

Ask a Question