Solution for Cannot find ActionMappings or ActionFormBeans collection

I got the error , Cannot find ActionMappings or ActionFormBeans collection  , when i run my application developed using the framework  struts 1.2 and deployed using WebSphere Application Server with Linux OS. The same application works fine with IDE WSAD. The above error is thrown when the application server executes the  following line.

<html:form name=”loginForm” type=”Sales.login.LoginForm” method=”post” scope=”request” action=”/login.do” onsubmit=”return submitForm()” >

The above error may occur due to various reasons.

Some of the situations  where the error may be thrown are as follows

Situation 1 :  When the Request Processor  searches for  the mapping of  this request, if  it is not able to  find the mappings that  are defined in the struts-config.xml , the following errors may be thrown depending upon the situation.

a)  If  the server is able to load the struts-config.xml , but the   mapping  is not available in the struts-config.xml . for eg.  if  the JSP has  <html:form action=”/login” method=”post” type=”LoginAction”>
                        then your struts-config.xml should have mapping for action parameter i.e. “/login”  something like

<action-mappings>
    <action path=”/login”    type=”LoginAction”    name=”loginForm”   scope=”request”       validate=”false”   input=”/login.jsp”>
    <action>
<action-mappings>

But if the mapping is not present in the   struts-config.xml , then you may get the error    [Cannot retrieve mapping for action /login1]: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /login

b) But the above mapping is present in the struts-config.xml  , but you are getting the error  Cannot find ActionMappings or ActionFormBeans collection   ,  That means the sever is not able to load the struts-config.xml file.

To solve , the above problem ,  Please ensure , the path &amp; file name of struts-config.xml file mentioned in the web.xml file  is correct and case sensitive.

In our  case , the problem was very silly and the problem got solved when i  add a slash (/) infront of WEB-INF …

The belows lines are part of the web.xml and the param-value  to be passed to  ActionServlet is wrongly mentioned

<servlet>
 <servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>   OR   <param-value>/web-inf/struts-config.xml</param-value>    // Wrong
</init-param>

In the above lines  , changing  the line   <param-value>WEB-INF/struts-config.xml</param-value> OR  <param-value>web-inf/struts-config.xml</param-value>;  to

<param-value>/WEB-INF/struts-config.xml</param-value>  , will solve the problem

Situation 2 :   If   the sever is able to load the struts-config.xml file and also the  mapping is present in the struts-config.xml , then the Request Processor does  process  any ActionForm bean related to this request. (i.e. finding , loading  the ActionFormBeans collection, ..etc ) .

             Various classes such as org.apache.struts.action.ActionFormBeans ,  org.apache.commons.collections.FastHashMap   are involved for the above process.  And the following jars are  involved
                 struts.ear
                 commons-collections.jar
                  commons-beanutils.jar
….
…..

           So  If you miss the jar files such as    commons-collections.jar  , commons-beanutils.jar in the class path , then the request processor may not find the ActionFormBeans collection , and the error Cannot find ActionMappings or ActionFormBeans collection  is thrown

You may also like

Leave a Reply