Results 1 to 4 of 4
  1. #1
    midani is offline Member
    Join Date
    Apr 2012
    Location
    Indianapolis, Indiana
    Posts
    2
    Rep Power
    0

    Default 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()

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default 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,
    1. getDisplayLifeReviewForHome() does not take arguements.
    2. getDisplayLifeReviewForHome() does not return a value.
    3. I have no idea what type the variable _displayLifeReviewForUser is.
    4. from your current track record, does the method _loadUserValues( agt ); actually take arguments?
    5. 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.
    6. 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

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default 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.

  4. #4
    BLuFeNiX is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default 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

  1. NullPointerException
    By mangesh.gho in forum New To Java
    Replies: 11
    Last Post: 01-21-2012, 06:19 AM
  2. nullpointerexception
    By natdizzle in forum New To Java
    Replies: 3
    Last Post: 01-14-2012, 09:57 PM
  3. NullPointerException
    By GPB in forum New To Java
    Replies: 8
    Last Post: 02-21-2010, 03:05 PM
  4. NullPointerException
    By Juuno in forum New To Java
    Replies: 1
    Last Post: 02-11-2010, 05:43 PM
  5. Why do I get a NullPointerException?
    By nessa203 in forum New To Java
    Replies: 2
    Last Post: 01-12-2010, 04:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •