Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Null Pointer Exception. How to fix this problem?

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Null Pointer Exception. How to fix this problem?

    I'm a newbie coder, programmer, computer science student.

    My project just received this error called null pointer exception.

    java.lang.NullPointerException
    	servlet.AddRewardsPages.doPost(AddRewardsPages.java:119)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
     
     
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.34 logs.

    How to get rid of this, so that my project works well?


  2. #2
    Junior Member
    Join Date
    Jan 2013
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Null Pointer Exception. How to fix this problem?

    Go to line number 119 (as clearly mentioned in the stacktrace) of your servlet class named AddRewardsPages.java and check for the variable in that line which is used. That variable must be null. Try printing the variable and run the application again so as to see what it is returning.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Null Pointer Exception. How to fix this problem?

    Quote Originally Posted by Pratyush View Post
    Go to line number 119 (as clearly mentioned in the stacktrace) of your servlet class named AddRewardsPages.java and check for the variable in that line which is used. That variable must be null. Try printing the variable and run the application again so as to see what it is returning.
    Thanks.

    I'll get right on it.

    --- Update ---

    Quote Originally Posted by carbLoading2012 View Post
    Thanks.

    I'll get right on it.
    Wait, what exactly do you mean to print it?

    Here is my code where this is happening
    if (valid) {
     
    					Reward reward = new Reward(new Integer(pledgeAmount), rewardDescription, request.getSession(true).getAttribute("USER").toString());
     
    			Line	119. -->  project.addReward(reward);
     
    					request.getSession(true).setAttribute("PROJECT", project);
     
    					pledgeAmount = "";
     
    					rewardDescription = "";
    				}				
    			}


    --- Update ---

    Alright...

    I received the error on a different part of the application...
    ava.lang.NullPointerException
    	servlet.Projects.doGet(Projects.java:171)
    	servlet.Projects.doPost(Projects.java:201)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	servlet.AddReward.doPost(AddRewardsPages.java:68)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722



    What do I do with this?

    The same thing that was recommended in a previous thread.

Similar Threads

  1. Need Help with Null Pointer Exception
    By kendraheartt in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 23rd, 2012, 02:20 PM
  2. Re: null pointer exception problem
    By tbarbone in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 2nd, 2011, 08:56 PM
  3. null pointer exception problem
    By vandrop in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 2nd, 2011, 01:45 PM
  4. Null Pointer Exception Help !!
    By AlterEgo1234 in forum Member Introductions
    Replies: 1
    Last Post: March 27th, 2011, 10:07 AM
  5. [SOLVED] Fixed Null Pointer Exception but still have another problem
    By javapenguin in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 29th, 2010, 10:16 PM

Tags for this Thread