• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionMapping being null

 
Sam Gehouse
Ranch Hand
Posts: 281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic