Results 1 to 4 of 4
- 08-15-2012, 08:07 PM #1
Member
- Join Date
- Apr 2012
- Location
- Indianapolis, Indiana
- Posts
- 2
- Rep Power
- 0
Please help with NullPointerException
Hello I have been going over a nasty NullPointerException for the past day or so. I am really stumped.
Any help would be appreciated. This is the servlet Context.java in the lib folder of my dynamic java application.
It doesn't seem to matter if I set the following:
if (getDisplayLifeReviewForHome( agt ).equals( TRUE ))
if (getDisplayLifeReviewForHome( agt ).equals( FALSE ))
I get the same error every single time no matter what.
The code is this:
Java Code:void getDisplayLifeReviewForHome() { System.err.println ("Can't Find Display Life Review for Home !!! " ); } void getDisplayLifeReviewForUser() { System.err.println ("Can't Find Display Life Review for User !!! " ); } public String getDisplayLifeReviewForUser( BcSQLAgent agt ) throws Exception { if (getDisplayLifeReviewForHome( agt ).equals( TRUE )) { if (_displayLifeReviewForUser == null) { _loadUserValues( agt ); } return _displayLifeReviewForUser; } else { return FALSE; } } // getDisplayLifeReviewForUser()
- 08-15-2012, 08:20 PM #2
Re: Please help with NullPointerException
Well, i do not believe you have given us enough information about this problem. This is more like a new to java problem, but whatevs.
Alright,
- getDisplayLifeReviewForHome() does not take arguements.
- getDisplayLifeReviewForHome() does not return a value.
- I have no idea what type the variable _displayLifeReviewForUser is.
- from your current track record, does the method _loadUserValues( agt ); actually take arguments?
- if _displayLifeReviewForUser; is a string, you should not be using ==. you should be using _displayLifeReviewForUser.equals("") || _displayLifeReviewForUser.isEmpty() || _displayLifeReviewForUser.trim().isEmpty() or something along those lines.
- edit: forgot. return FALSE;... shouldn't it be return "FALSE"; since you are returning a string.
Lastly, what are you runtime errors. Where is the nullPointerException? why haven't you written a try {} catch(nullPointerException e) { } after see the nullPointerEXception?
Last edited by kammce; 08-15-2012 at 08:22 PM.
My API:Java Code:cat > a.out || cat > main.class
- 08-16-2012, 09:40 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Please help with NullPointerException
No point sticking in a try/catch in there unless somewhere higher up the chain they aren't logging the exception properly (complete with stack trace).
You generally shouldn't be trying to catch NPEs, as they're usually an error in the code and catching them may well result in that error being hidden.Please do not ask for code as refusal often offends.
- 09-01-2012, 07:52 AM #4
Member
- Join Date
- Dec 2011
- Posts
- 9
- Rep Power
- 0
Re: Please help with NullPointerException
You code shows a lack of Java fundamentals. If you post the entire code, we can try to help you get it into working order, but as it is, your code is indecipherable. I can already see 6 different ways to interpret what you want to do. What, over all, are you trying to accomplish?
Similar Threads
-
NullPointerException
By mangesh.gho in forum New To JavaReplies: 11Last Post: 01-21-2012, 06:19 AM -
nullpointerexception
By natdizzle in forum New To JavaReplies: 3Last Post: 01-14-2012, 09:57 PM -
NullPointerException
By GPB in forum New To JavaReplies: 8Last Post: 02-21-2010, 03:05 PM -
NullPointerException
By Juuno in forum New To JavaReplies: 1Last Post: 02-11-2010, 05:43 PM -
Why do I get a NullPointerException?
By nessa203 in forum New To JavaReplies: 2Last Post: 01-12-2010, 04:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks