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 ActionMapping being null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionMapping being null" Watch "ActionMapping being null" New topic
Author

ActionMapping being null

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
protected ActionForward subclassExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

return mapping.findForward("go to some URL");

}

Has anyone ever seen mapping (shown above) variable being null in a Struts based application?

mapping is null. As such, mapping.findForward("go to some URL") throws NullPointerException.

Mapping is used only once within the entire class, which is inside the method above.

struts_config.xml is properly configured.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The only way that the Struts ActionServlet can call the execute() method of an Action class is by finding the class through an Action mapping. Therefore, if the mapping does not exist, there's no way Struts can even find the class or call the execute method on it.

The answer to your question, then, is no, I have never seen a case where the ActionMapping passed in to the execute() method of an Action class was null.

However, your case is a little different. Since the name of your method is subclassExecute instead of execute, I'm guessing that your action class is extending a base Action class that you've written that in turn extends org.apache.struts.action.Action.

The most obvious possibility here is that when the execute method of your base Action class calls subclassExecute, it does not properly pass the ActionMapping that it received from Struts. I would look to your base Action class for the problem.


Merrill
Consultant, Sima Solutions
 
GeeCON Prague 2014
 
subject: ActionMapping being null