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.
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
Joined: Feb 08, 2006
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?