File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Strange Null Pointer Exception in ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange Null Pointer Exception in ActionForm" Watch "Strange Null Pointer Exception in ActionForm" New topic
Author

Strange Null Pointer Exception in ActionForm

Kedar Patwardhan
Greenhorn

Joined: Jan 24, 2007
Posts: 8
Hi,

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.

NOW THE ACTUAL PROBLEM :

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???

Phew...

Please help me out if anybody knows about this.

Thanks in advance

Regards,
Kedar
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange Null Pointer Exception in ActionForm
 
Similar Threads
NULL Pointer Exception from the class which extends Hash Map. urgent help please
Dynamic Table
NULL Pointer Exception from the class while accessing from EJB/ HttpSession
enctype="multipart/form-data" request.getParameter() issue
Dispatch VS LookupDispatch