This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes I need a help to solve this error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "I need a help to solve this error" Watch "I need a help to solve this error" New topic
Author

I need a help to solve this error

shashibabu kiran
Greenhorn

Joined: Mar 04, 2010
Posts: 6
Hi guys,

i got following error when i run my first struts application


org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index_jsp._jspService(index_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:711)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:419)
org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:97)
org.apache.jsp.index_jsp._jspService(index_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


my

web.xml


<?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">

<web-app>
<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->
<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>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>





<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
</web-app>


struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>



<!-- ======================================== Form Bean Definitions -->

<form-beans>
<form-bean name="nameForm" type="example.NameForm"/>
</form-beans>

<!-- =================================== Action Mapping Definitions =========================-->

<action-mappings>
<action path="/Name" type="example.NameAction" name="nameForm" input="/index.jsp">
<forward name="success" path="/displayname.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
</action-mappings>



<!-- ================================ Message Resources Definitions -->

<message-resources parameter="resources.application"/>

</struts-config>

my jsp index.jsp

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
<title>Sample Struts Application</title>
</head>
<body>
<html:form action="Name">
Name: <html:text property="name" />
<html:submit />

</html:form>
</body>
</html>




Thanks in advance


Regards,
shashikiran b.s
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
I think there is some problem with Action that you have specified in form tag on jsp page. Please check corresponding action and form mapping whether they are correct or not. It will be better if you can send related files to find out exact cause.
shashibabu kiran
Greenhorn

Joined: Mar 04, 2010
Posts: 6
I changed form tag of the index.jsp now i m getting this error

org.apache.jasper.JasperException: Exception in JSP: /index.jsp:4

1: <%@ page language="java" %>
2: <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
3: <html:html>
4: <html:form action="/login.do" method="post">
5: <table width="80%" border="0">
6: <tr>
7: <td>Name:</td>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index_jsp._jspService(index_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:711)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:419)
org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:123)
org.apache.jsp.index_jsp._jspx_meth_html_005fhtml_005f0(index_jsp.java:96)
org.apache.jsp.index_jsp._jspService(index_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)



index.jsp


<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<html:form action="/login.do" method="post">
<table width="80%" border="0">
<tr>
<td>Name:</td>
<td><html:text property="name" /></td>
</tr>
<tr>
<td><html:submit /></td>
</tr>
</table>
</html:form>

</html:html>


web.xml


<?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">

<web-app>
<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->
<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>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>





<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
</web-app>


struts-config.xml


<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>



<!-- ======================================== Form Bean Definitions -->

<form-beans>
<form-bean name="nameForm" type="example.NameForm"/>
</form-beans>

<!-- =================================== Action Mapping Definitions =========================-->

<action-mappings>
<action path="/login" type="example.NameAction" name="nameForm" input="/index.jsp">
<forward name="success" path="/displayname.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
</action-mappings>



<!-- ================================ Message Resources Definitions -->

<message-resources parameter="resources.application"/>

</struts-config>






Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
http://faq.javaranch.com/java/UseAMeaningfulSubjectLine
http://faq.javaranch.com/java/UseCodeTags
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
everything seems fine. I think this is version problem, try with following code as doctype i.e use 1.1 instead of 1.2


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're accessing the JSP page directly the Struts tags will not work.
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
David Newton wrote:If you're accessing the JSP page directly the Struts tags will not work.

is it? If yes, Why is this? I think it struts tag should work in any case either we access directly or indirectly.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Ravishanker kumar wrote:I think it struts tag should work in any case either we access directly or indirectly.

That's because you don't know what the Struts form tags do.

Struts form tags look for the form bean, pre-fill the form fields, display field error messages, and so on. Without normal Struts processing, none of that will work, and they will break.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I need a help to solve this error
 
Similar Threads
JspException: Cannot find ActionMappings or ActionFormBeans
Cannot find ActionMappings or ActionFormBeans
ERROR :: cannot find ActionMappings or ActionFormBeans
Cannot find ActionMappings or ActionFormBeans collection
Cannot find ActionMappings or ActionFormBeans