Get your CodeRanch badge!*
The moose likes Struts and the fly likes Cannot find ActionMappings or ActionFormBeans collection with dbcp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot find ActionMappings or ActionFormBeans collection with dbcp" Watch "Cannot find ActionMappings or ActionFormBeans collection with dbcp" New topic
Author

Cannot find ActionMappings or ActionFormBeans collection with dbcp

kunal green
Greenhorn

Joined: Dec 31, 2009
Posts: 26



Cannot find ActionMappings or ActionFormBeans collection error is showing when i am executing th folloewing code on a trial basis.


....................................................................................................................

the struts-config.xml is




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>


<data−sources>
<data−source
type="org.apache.commons.dbcp.BasicDataSource">
<set−property property="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<set−property property="url"
value="jdbcracle:thin:@localhost:1521:XE" />
<set−property property="username"
value="system"/>
<set−property property="password"
value="kunal"/>
</data−source>
</data−sources>



<form-beans>
<form-bean name="LookupForm"
type="struts2.pack.LookupForm"/>
</form-beans>

<action-mappings>
<action path="/Lookup"
type="struts2.pack.LookUpAction"
name="LookupForm" >
<forward name="success" path="/success.jsp" />
<forward name="failure" path="/failure.jsp"/>
</action>
</action-mappings>

</struts-config>




...............................................................................................................................
web.xml is




<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>struts2nd</display-name>

<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>1</load-on-startup>
</servlet>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>


<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

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

<taglib>
<taglib-uri>/tags/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
</jsp-config>




</web-app>






...................................................................................................................
action form is


package struts2.pack;
import java.io.*;
import javax.sql.DataSource;

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import java.sql.*;
public class LookUpAction extends Action
{
private static final long serialVersionUID = 1L;
//why protected???
protected boolean getValue(String name,String age,HttpServletRequest request)
{
Double price=null;
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
DataSource ds=null;

try
{
ds=getDataSource(request);
con=ds.getConnection();
stmt=con.createStatement();
rs=stmt.executeQuery("select * from sdp_cp_name1");
while(rs.next())
{
System.out.println(rs.getString("cp_name"));
}

}
catch(Exception e)
{System.out.println("exception message is"+e.getMessage());}


if(name.equals("kunal") && age.equals("25"))
return true;
else
return false;
}

@Override
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
String myname=null;
String myage=null;
String target=new String("success");


if(form!=null)
{
LookupForm lookupform=(LookupForm)form;
myname=lookupform.getName();
myage=lookupform.getAge();
Boolean b=getValue(myname,myage,request);
if(b==false)
{
target =new String("failure");
}
}

return(mapping.findForward(target));
}
}



.......................................................................................................
beanform is



package struts2.pack;
import javax.servlet.http.*;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;


public class LookupForm extends ActionForm
{
private static final long serialVersionUID = 1L;
private String name=null;
private String age=null;

public void setName(String name)
{
this.name=name;
}

public void setAge(String age)
{
this.age=age;
}

public String getName()
{
return name;
}

public String getAge()
{
return age;
}

@Override
public void reset(ActionMapping mapping,HttpServletRequest request)
{
this.name=null;
this.age=null;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////

the error i am getting is




javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:795)
org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.index_jsp._jspx_meth_html_form_0(index_jsp.java:100)
org.apache.jsp.index_jsp._jspService(index_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


--------------------------------------------------------------------------------

removing the datasource entry from the struts-config.xml the error is removed and success and failure pages are working properly
as i m inserting the datasource part is not working
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.

And welcome to JavaRanch!
 
 
subject: Cannot find ActionMappings or ActionFormBeans collection with dbcp
 
Similar Threads
Cannot find ActionMappings or ActionFormBeans
Cannot find ActionMappings or ActionFormBeans collection
Cannot find ActionMappings or ActionFormBeans collection
Cannot find ActionMappings or ActionFormBeans
ERROR :: cannot find ActionMappings or ActionFormBeans