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

    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 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;
            return FALSE;
        }  // getDisplayLifeReviewForUser()

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Rep Power

    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.

    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
    Rep Power

    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.

    ** This space for rent **

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

    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, 07:19 AM
  2. nullpointerexception
    By natdizzle in forum New To Java
    Replies: 3
    Last Post: 01-14-2012, 10:57 PM
  3. NullPointerException
    By GPB in forum New To Java
    Replies: 8
    Last Post: 02-21-2010, 04:05 PM
  4. NullPointerException
    By Juuno in forum New To Java
    Replies: 1
    Last Post: 02-11-2010, 06:43 PM
  5. Why do I get a NullPointerException?
    By nessa203 in forum New To Java
    Replies: 2
    Last Post: 01-12-2010, 05: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