facebook

Cannot find ActionMappings or ActionFormBeans [Closed]

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #224092 Reply

    umbersp
    Member

    500 Internal Server Error

    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
    void org.apache.struts.taglib.html.FormTag.lookup()
    FormTag.java:798
    int org.apache.struts.taglib.html.FormTag.doStartTag()
    FormTag.java:506
    void _form._test._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    [/form/test.jsp]
    _test.java:57

    Found the answer to this error here: http://threebit.net/tutorials/ejb/general/

    <html:form>, ActionMappings and ActionForms. This one took me a few days to figure out. When using the <html:form> tag, either JBoss or Tomcat will not create / parse the struts-config.xml document until *after* a post to the ActionServlet. Now that I’m typing this out it makes total sense but I still wasted a few days on it nonetheless.

    If you are getting the Cannot find ActionMappings or ActionFormBeans collection exception when accessing a JSP page, manually make a request to the ActionServlet. Most example code suggests this URL would be something like

    http://localhost/your_web_app/action/blah
    http://localhost/your_web_app/some/nested/url/your_action.do

    You don’t need to send this manual request to a real Action – so long as the container maps the request to the ActionServlet you’re OK. In my environment I simply use an Ant <get> task to hit

    http://localhost:8080/my_web_app/action/dumbHackToAvoidThisProblemSmileyFace

    Also, anytime the web application is reloaded this procedure needs to be repeated.

    Doh!. After all that, I just learnt that all you need to do is direct the servlet container to load the servlet on startup by adding a <load-on-startup>5</load-on-startup> directive to the <servlet> section in web.xml.

    org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

    By hitting an action class directly (via a *.do URL) I can force the servlet to load/parse the struts-config file, after which the JSP’s work fine. Now, the question is: why doesn’t the load-on-startup=0 in the web.xml cause this to happen in the first place?

    #224095 Reply

    Riyad Kalla
    Member

    Damn nice catch, that is a very obscure probelm that I wasn’t even aware of. Thank you very much for posting the solution.

    #224116 Reply

    umbersp
    Member

    Damn nice catch, that is a very obscure probelm that I wasn’t even aware of. Thank you very much for posting the solution.

    You’re welcome, but full credit to ThreeBit (whoever they are) for figuring it out in the first place. Incidentally, the problem only occurs on application servers which do not honour the load-on-startup parameter in the web.xml file. Tomcat, it seems, does honour this setting by default whereas Oracle 9i/AS (ie: Orion) does not.

    On IAS, the load-on-startup setting has to be added manually to the entry for the web application in the config/http-web-site.xml file. The down side to this is that if you undeploy an app remotely this entry gets hacked from the file so the next time you deploy another entry is added and, bingo, the problem is back again. I’m looking now to see if there’s a way around this but I’ve not found one yet. Good old Oracle, eh.

    #254013 Reply

    Cameron Lauseng
    Participant

    The way I had to solve it was to fixup the web.xml that MyEclipse generates for struts applications.

    I found reason that the MyEclipse deployments don’t work under JRun is because the Jrun server implementation isn’t picking up the tld’s out of the WEB-INF folder automatically. The taglibs must be specified in the web.xml. If you look at the Jakarta struts examples, you can see where the taglib specifications go in the web.xml. JBoss and Tomcat deployments from MyEclipse works out of the box, because MyEclipse is building the web.xml under a specification for custom tag inclusion not supported by Jrun. To fix this, I had to do the following to the web.xml MyEclipse generates:

    1) At the top, change the <?xml and <webapp tags to the following:
    <?xml version=”1.0″ encoding=”iso-8859-1″?>
    <!DOCTYPE web-app
    PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN”
    http://java.sun.com/j2ee/dtds/web-app_2_2.dtd”&gt;
    <web-app>

    Next, add the following tags under the </servlet-mapping> tag, but before the </webapp> end tag:

    <!– Struts Tag Library Descriptors –>
    <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>

    If you use the struts panels tags, remember to add that taglib specification to your web.xml as well.

    The example for the web.xml I found to work is in the Jakarta download for the newest release of struts 1.2.9. It would be nice if MyEclipse construction of web.xml for struts implementation followed the Jakarta example sites, it would have saved me quite a bit of time figuring this out.

Viewing 4 posts - 16 through 19 (of 19 total)
Reply To: Cannot find ActionMappings or ActionFormBeans [Closed]

You must be logged in to post in the forum log in