Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.servlet. Servlet Exception: No getter method for property

 
anuradha Java
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to run one query using struts + hibernate

the query which is i have run through sqlplus is:

SELECT IC_NAME, IC_DESCRIPTION, CONTROL_OBJECTIVE, RISK_NAME, RISK_DESC, PROCESS_NAME, PROCESS_DESC, ORGANIZATION_NAME
FROM GLT_INTERNAL_CONTROLS, GLT_RISKS, GLT_PROCESSES, GLT_ORGANIZATIONS
WHERE GLT_INTERNAL_CONTROLS.RISK_ID = GLT_RISKS.RISK_ID
AND GLT_RISKS.PROCESS_ID = GLT_PROCESSES.PROCESS_ID
AND GLT_INTERNAL_CONTROLS.ORGANIZATION_ID = GLT_ORGANIZATIONS.ORGANIZATION_ID;

I have created hbm.xml files as well as POJO for all of these tables.

then created on action class and called one method from the action class.
the method should contain the query and return the List.

The List will put in the setAttribute() method and will iterate from jsp.

so tell me how to write the method using hibernate which will the return result as a List.


actually i have return one method which contains very small part of the actual query. It is as below:

public static List searchControls()
{
InternalControl internalcontrols = new InternalControl();
Process process = new Process();
Risk risk = new Risk();
Organization organization = new Organization();

//create session object to get the fiels in the session
Session session = HibernateUtil.currentSession();
java.sql.Connection connection = session.connection();
List list = new ArrayList();
List cols = new ArrayList();
String query = null;
try{
query = " select IC_NAME, IC_DESCRIPTION, CONTROL_OBJECTIVE, RISK_NAME, RISK_DESC, PROCESS_NAME, " +
"PROCESS_DESC, ORGANIZATION_NAME " +
"FROM GLT_INTERNAL_CONTROLS, GLT_RISKS, GLT_PROCESSES, GLT_ORGANIZATIONS " +
"WHERE GLT_INTERNAL_CONTROLS.RISK_ID = GLT_RISKS.RISK_ID " +
"AND GLT_RISKS.PROCESS_ID = GLT_PROCESSES.PROCESS_ID " +
"AND GLT_INTERNAL_CONTROLS.ORGANIZATION_ID = GLT_ORGANIZATIONS.ORGANIZATION_ID" ;

PreparedStatement statement = connection.prepareStatement(query);

ResultSetrs = statement.executeQuery();
ARUsers user = new ARUsers() ;

while(rs.next()){
internalcontrols.setIcName(rs.getString("IC_NAME"));
internalcontrols.setIcDescription(rs.getString("IC_DESCRIPTION"));
internalcontrols.setControlObjective(rs.getString("CONTROL_OBJECTIVE"));
risk.setRiskName(rs.getString("RISK_NAME"));
risk.setRiskDesc(rs.getString("RISK_DESC"));
process.setProcessName(rs.getString("PROCESS_NAME"));
process.setProcessDesc(rs.getString("PROCESS_DESC"));
organization.setOrganizationName(rs.getString("ORGANIZATION_NAME"));

list.add(internalcontrols);
list.add( risk);
list.add(process);
list.add(organization);



}
}catch (SQLException e) {
e.printStackTrace();
}

return list;


}


Action class is:

if(path.equals("/controlSelect") )
{
try
{
_logger.info("in /controlSelect");
List controls = new ArrayList();
InternalControl internalcontrols = new InternalControl();
Process process = new Process();
Risk risk = new Risk();
Organization organization = new Organization();

controls = CommonDAO.searchControls();
_logger.info("fetching from searchControls");
if(controls.size() == 0)
{
request.setAttribute("NoRecords", "NoRecords");
System.out.println("*********************** m inside the control size if ");
}
else
{
request.getSession().setAttribute("Controls", controls);
System.out.println("************ m inside the control size else "+controls.size());
}


forward = actionMapping.findForward("selectControl");
_logger.info("forward to selectControl");
}
catch(Exception e)
{
e.printStackTrace();
forward = actionMapping.findForward("error");
}





}//end of class
return forward;
}



JSP is :
<!--hello123
file name: controlDetails.jsp
version: TRAC 2.01
modified:jan 28/08 by indrayani.kunte
descr:
-->
<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic" prefix="logic" %>

<html>
<head>
<title>Select Controls</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="styleSheet" href="act/assets/actStyleSheet.css" type="text/css">
<link href="act/assets/main.css" rel="stylesheet" type="text/css" media="all" />

</head>
<body>
<table width="100%" cellspacing="0" cellpadding="0" border="0" valign="top">
<tr >


<th>
Control Name
</th>

<th>
Control description
</th>

<th>
Control Objective
</th>

<th>
Risk Name
</th>

<th>
Risk Desc
</th>

<th>
Process Name
</th>

<th>
processDesc
</th>

<th>
Organization Name
</th>

<th class="column_header">
 
</th>
</tr>
</tr>
<logic resent name="NoRecords" scope="session">
<tr>
<td colspan="5" align="center"><h2>No Record Found</h2></td>
</tr>
</logic resent>

<logic:notPresent name="NoRecords" >
<%
int counter = 0 ;
String bgColor = "" ;
%>
<logic resent name="Controls" scope="session">
<logic:iterate id="control" name="Controls" scope="session">

<%
if( counter % 2 != 0 ){
bgColor="oddTableRow" ;
}else
bgColor="" ;
counter++ ;
%>
<tr id="ci_incorrect<%= counter %>" class="<%=bgColor%>">
<td>
<bean:write name="control" property="icName" />
</td>
<td>
<bean:write name="control" property="icDescription" />
</td>
<td>
<bean:write name="control" property="controlObjective" />
</td>
<td>
<bean:write name="control" property="riskName" />
</td>
<td>
<bean:write name="control" property="riskDesc" />
</td>
<td>
<bean:write name="control" property="processName" />
</td>
<td>
<bean:write name="control" property="processDesc" />
</td>
<td>
<bean:write name="control" property="organizationName" />
</td>
<td class="column_header">
 
</td>
</tr>
</logic:iterate>
</logic resent></tr>
</logic:notPresent>
</table>

</body>

</html>


Struts-config file entry:

<action path="/controlSelect" name="InternalControl" scope="session" type="com.greenlight.testxpert.struts.action.ControlSelectAction">
<display-name>Entity Details </display-name>
<forward name="selectControl" path="/act/navigation/selectControl.jsp" />
<forward name="success" path="/act/success.jsp" />
</action>


and also i have checked all the bean classes and hbm.xml files for naming conventions, all they are correct.



the exception is:

javax.servlet.ServletException: No getter method for property icName of bean control
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.act.navigation.selectControl_jsp._jspService(selectControl_jsp.java:243)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: No getter method for property icName of bean control
org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1031)
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:227)
org.apache.jsp.act.navigation.selectControl_jsp._jspx_meth_bean_write_0(selectControl_jsp.java:289)
org.apache.jsp.act.navigation.selectControl_jsp._jspService(selectControl_jsp.java:194)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
Ashutosh kumar singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to define one pojo class corrosponding to each hbm file. in which some getter setter method according to property. Go through hibernate example. and visit www.roseindia.net and search hibernate example with any framework.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic