• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionMapping being null

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic