File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark ""No getter method for property ..." error" Watch ""No getter method for property ..." error" New topic

"No getter method for property ..." error

Tony Walters
Ranch Hand

Joined: Feb 13, 2003
Posts: 54
Hi all

I'm getting a "no getter method for property firstName of bean org.apache.struts.taglib.html.BEAN" error while processing the following page:

// createBio.jsp
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-nested.tld" prefix="nested" %>

<html:errors />
<html:form action="/" focus="firstName">
<html:text property="firstName" />
<html:text property="lastName" />
<html:submit />

The obvious mistake (from reading around) is inappropriate naming of the fields/ accessors and mutators in the ActionForm, here it is:

* ActionForm to hold details of Bio (including Employments and Tracks).
public class BioForm extends ActionForm {
// The fields.
private String id;
private String firstName;
private String lastName;
private String gender;
private String ethnicity;
private String role;
private List employments;
private List tracks;
// Accessors & mutators for the fields.
public void setId(String id) { = id;}
public String getId() {return id;}
public void setFirstName(String firstName) {this.firstName = firstName;}
public String getFirstName() {return firstName;}
public void setLastName(String lastName) {this.lastName = lastName;}
public String getLastName() {return lastName;}
public void setGender(String gender) {this.gender = gender;}
public String getGender() {return gender;}
public void setEthnicity(String ethnicity) {this.ethnicity = ethnicity;}
public String getEthnicity() {return ethnicity;}
public void setRole(String role) {this.role = role;}
public String getRole() {return role;}
public void setEmployments(List employments) {this.employments = employments;}
public List getEmployments() {return employments;}
public void setTracks(List tracks) {this.tracks = tracks;}
public List getTracks() {return tracks;}
* Reset the fields.
public void reset() {
id = null;
firstName = null;
lastName = null;
gender = null;
ethnicity = null;
role = null;
employments = null;
tracks = null;
* Validate the fields.
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(firstName == null || firstName.length() < 1) {
errors.add("firstName", new ActionError("error.required"));
if(lastName == null || lastName.length() < 1) {
errors.add("lastName", new ActionError("error.required"));
return errors;

Here is the config:

<forward name="success" path="" />

Any ideas/ suggestions gratefully received!
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Your jsp uses but your struts-config snippet is for

A good workman is known by his tools.
Tony Walters
Ranch Hand

Joined: Feb 13, 2003
Posts: 54
I thought the page was where the form was being submitted to. Am I missing something?
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi tony

action should be /add... rather than view as stated earlier its not the req from where it comes .i hope u r getting what we mean
Tony Walters
Ranch Hand

Joined: Feb 13, 2003
Posts: 54
Ok, I think its just that I have been missing something. This does now work. Not sure I completely understand it, but will go through it slowly. Thanks for the help!
I agree. Here's the link:
subject: "No getter method for property ..." error
It's not a secret anymore!