File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts help needed for error No getter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts help needed for error No getter method" Watch "struts help needed for error No getter method" New topic
Author

struts help needed for error No getter method

alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
hello everybody
Friends i am new into struts a helpinghand from you will enable me to master this technology
friends i am getting the following error:
org.apache.jasper.JasperException: No getter method for property desig of bean designation
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
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)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:536)


root cause

javax.servlet.ServletException: No getter method for property desig of bean designation
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.designationlist_jsp._jspService(designationlist_jsp.java:155)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
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)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:536)


my designationlist.jsp is as follows
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html>
<head>
<title><bean:message key="app.title" /></title>
</head>
<body>

<table width="650"
border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td height="68" width="48%">
<div align="left">

</div>
</td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
</table>

<html:errors />

<table width="700"
border="0" cellspacing="0" cellpadding="0">
<tr align="left">
<th><bean:message key="app.username" /></th>

</tr>
<!-- iterate over the results of the query -->
<logic:iterate id="designation" name="designations">
<tr align="left">
<td>
<bean:write name="designation" property="desig" />
</td>

</td>
<td>

</td>
</tr>
</logic:iterate>
<tr>
<td colspan="7">
<hr>
</td>
</tr>
</table>
<font size="-1" face="arial">
<a href="adddesignation.jsp">Add New Designation</a>
</font>

</body>
</html>

DesignationData.java

package com.wrox;

import java.rmi.*;
import java.util.*;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
import teste.*;
import masters.designation.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.Date;
public class DesignationData {
public static Designations getDesignation(String desig, DataSource dataSource)
throws Exception {

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Designations designation = null;
try {

conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from designation where desigName=\'"
+ desig + "'");

if ( rs.next() ) {

designation = new Designations();

designation.setDesig(rs.getString("desig"));

}
else {

throw new Exception("Designation " + desig + " not found!");
}
}

finally {

if ( rs != null ) {

rs.close();
}
if ( stmt != null ) {

stmt.close();
}
if ( conn != null ) {

conn.close();
}
}
return designation;
}

public static Collection getDesignations() {

Designations designation = null;
Collection designations = null;
//Collection d=null;



try {
System.out.println("in function getDesignations ");
Context ic = new InitialContext();
Object o = ic.lookup("ejb/Example/Designation");
DesignationHome home = (DesignationHome) PortableRemoteObject.narrow(o, DesignationHome.class);
Designation dn=null;
designations = home.findAll();
Object[] a = designations.toArray();
//Iterator i=d.iterator();
System.out.println("stage 1");
for(int k=0;k<a.length;k++)
{
System.out.println("sanjay"+a[k].toString());
designation = new Designations();
//Designations ds=new Designations();
designation.setDesig(a[k].toString());
designations.add(designation);
System.out.println("stage 2");
}

}

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

return designations;
}

public static void removeDesignation(String desig, DataSource dataSource)
throws Exception {

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {

conn = dataSource.getConnection();
stmt = conn.createStatement();

StringBuffer sqlString =
new StringBuffer("delete from deignation ");
sqlString.append("where desigName='" + desig + "'");

stmt.execute(sqlString.toString());
}
finally {

if ( rs != null ) {

rs.close();
}
if ( stmt != null ) {

stmt.close();
}
if ( conn != null ) {

conn.close();
}
}
}

public static void addDesignation(Designations designation, DataSource dataSource)
throws Exception {

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {

/* conn = dataSource.getConnection();
stmt = conn.createStatement();
StringBuffer sqlString =
new StringBuffer("insert into employees ");

sqlString.append("values (\'"+ employee.getUsername() + "\', ");
sqlString.append("\'" + employee.getPassword() + "\', ");
sqlString.append("\'" + employee.getName() + "\', ");
sqlString.append( employee.getRoleid() +"," );
//sqlString.append("\'" + employee.getName() + "\', ");
sqlString.append("\'" + employee.getPhone() + "\', ");
sqlString.append("\'" + employee.getEmail() + "\', ");
sqlString.append(employee.getDepid() + ")");
System.out.println("The query before "+sqlString.toString());
stmt.execute(sqlString.toString());
System.out.println("The query after "+sqlString.toString());*/

Context ic = new InitialContext();
Object o = ic.lookup("ejb/Example/Designation");
DesignationHome home = (DesignationHome) PortableRemoteObject.narrow(o, DesignationHome.class);
Designation d=null;


d = home.create(designation.getDesig());
System.out.println("Recored inserted");
}
catch(Exception e)
{
e.printStackTrace();}
finally {

if ( rs != null ) {

rs.close();
}
if ( stmt != null ) {

stmt.close();
}
if ( conn != null ) {

conn.close();
}
}
}

public static void updateDesignation(Designations desig, DataSource dataSource)
throws Exception {

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {

conn = dataSource.getConnection();
stmt = conn.createStatement();

StringBuffer sqlString =
new StringBuffer("update designation ");

sqlString.append("set desigName='"
+ desig.getDesig() + "', ");

sqlString.append(" where desigName='"
+ desig.getDesig() + "'");

stmt.execute(sqlString.toString());
}
finally {

if ( rs != null ) {

rs.close();
}
if ( stmt != null ) {

stmt.close();
}
if ( conn != null ) {

conn.close();
}
}
}
}

DesignationListAction.java
package com.wrox;
import java.util.*;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import java.util.ArrayList;

public class DesignationListAction extends Action {

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

// Default target to success
String target = new String("success");

Collection designations = null;

designations = DesignationData.getDesignations();

request.setAttribute("designations", designations);

// Forward to the appropriate View
return (mapping.findForward(target));
}
}

DesignationForm.java
package com.wrox;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;

public class DesignationForm extends ActionForm {

protected String desig;


public void setDesig(String desig) {

this.desig = desig;
}

public String getDesig() {

return desig;
}

// This method is called with every request. It resets the Form
// attribute prior to setting the values in the new request.
public void reset(ActionMapping mapping, HttpServletRequest request) {

this.desig = "";
}

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {

ActionErrors errors = new ActionErrors();


if ( (desig == null) || (desig.length() == 0) ) {

errors.add("designation", new ActionError("errors.username.required"));
}
return errors;
}
}


Designations.java

/*
* Created on Dec 30, 2005
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.wrox;

/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Designations {
protected String desig;


public void setDesig(String desig) {

this.desig = desig;
}

public String getDesig() {

return desig;
}

}
Cendy Nguvy
Ranch Hand

Joined: May 25, 2005
Posts: 37
Change

in


and add a getter and a setter method on collection designations in your ActionForm DesignationForm.
Cendy Nguvy
Ranch Hand

Joined: May 25, 2005
Posts: 37
And add
before <logic:iterate>
 
wood burning stoves
 
subject: struts help needed for error No getter method
 
Similar Threads
New Exceptions can't create DynaActionForm
NullPointerException in PropertyUtils .getSimpleProperty()
Bean not in any scope
Stuts forwarding does not work
can anybody correct this error