• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

ActionMapping being null

 
Ranch Hand
Posts: 281
  • 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.
 
Ranch Hand
Posts: 4864
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!