• Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange Null Pointer Exception in ActionForm  RSS feed

Kedar Patwardhan
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have encountered an unexpected Null Pointer Exception.Let me explain everything about it.Following are the things which I am using in my application:

1)I have one file named "ParamsMap.java" wherein I am maintaining a HashMap to store values.

2)Another file named "ParamsInfoForm.java" which extends ActionForm.

3)One JSP File named "Params.jsp" which is having some 20 hidden parameters.

4)And one ActionClass "ParamsAction.java" which extends Action.

Now let me explain you what I am doing over here with these files.That is:

When I submit my "Params.jsp" my "ParamsInfoForm.java" will populate the FormBean then my Action i.e. "ParamsAction.java" will create an instance of this ActionForm class.

After that I am calling a method from "ParamsMap.java" and passing the instance of my ActionForm class i.e. "ParamsAction" through this method.Now this method will get the values of those 20 parameters with their "getters" and populate the values in the Hashmap.


Its giving me a java.lang.NullPointerException at the place where I am calling the method.

But I checked the values of instances of both "ParamsMap.java" and "ParamsActionForm.java" which gave me a Non-Null value.

Then why its throwing me a NULL POINTER on method call???


Please help me out if anybody knows about this.

Thanks in advance

Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The good thing about a NullPointerException is that the stack trace tells you exactly which line the error occurs. If you look at that specific line I suspect that there are only a couple things that could possibly be null. Please post your code and specify exactly which line is causing the exception.

I do not completely understand your flow. Are you saying that ParamsInfoForm has a property of type ParamsMap? Where do you initialize this property?

- Brent
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!