File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Cannot find bean: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot find bean: "EMPLOYEELIST" in any scope" Watch "Cannot find bean: "EMPLOYEELIST" in any scope" New topic

Cannot find bean: "EMPLOYEELIST" in any scope

Steve Huang

Joined: Aug 02, 2006
Posts: 2
Hi everyone,

This is my first post. Any help on this is much appreciated. I've been reading in Struts Forum about the proper usage of <html:select>, <html ptions>, <html ptionsCollection>, etc, honestly I am still confused. I am getting "cannot find bean: EMPLOYEELIST in any scope" error message. Can any of your struts experts tell me what I am doing wrong? Here is my code:

<html:form action="/search">
<td align="right"><bean:message key=""/>:</td>
<html:select property="employee">
<html ptionsCollection name="EMPLOYEELIST" value="ssNum" label="name"/>


<form-bean name="searchForm"

<!-- Global Forwards Configuration -->
<forward name="search" path="/search.jsp"/>

<!-- Action Mappings Configuration -->
<action path="/search"

public final class SearchAction extends Action
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
EmployeeSearchService service = new EmployeeSearchService();
ArrayList results;
ArrayList empList;

SearchForm searchForm = (SearchForm) form;
empList = service.getEmployeeList();



// Forward control to this Action's input page.
return mapping.getInputForward();

public class SearchForm extends ActionForm
private ArrayList employees = new ArrayList();
private String employee;

public String getEmployee() {
return employee;

public void setEmployee(String employee) {
this.employee = employee;

public ArrayList getEmployees() {
return employees;

public void setEmployees(ArrayList employees) {
this.employees = employees;

public class Employee
private String name;
private String ssNum;

public Employee(String name, String ssNum) { = name;
this.ssNum = ssNum;

public void setName(String name) { = name;

public String getName() {
return name;

public void setSsNum(String ssNum) {
this.ssNum = ssNum;

public String getSsNum() {
return ssNum;

Please help, thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Let's look more closely at this:

In the <htmlptionsCollection> tag, the name and (optionally) property attribute should refer to a collection of beans you want to iterate over to create the list of options.

You've provided name="EMPLOYEELIST", but the object in the session under the name "EMPLOYEELIST is an object of type SearchForm, not a collection, so that isn't going to work. What you're after is the employees property of SearchForm because that contains the actual list of employees you want to iterate over.

Stop reading and try fixing it yourself first. Then scroll down if you need to see the answer.

<htmlptionsCollection name="EMPLOYEELIST" property="employees" value="ssNum" label="name"/>

Just so you know: Struts has already put your SearchForm in the session for you. You could therefore eliminate the line:


and then change the name attribute of your <htmlptionsCollection> tag to "searchForm".

P.S. to get rid of those annoying smiley-faces, click the "Disable smilies in this post" box at the bottom of the Post A Reply page.

Consultant, Sima Solutions
Steve Huang

Joined: Aug 02, 2006
Posts: 2
Merrill, you're right! It was the problem setting incorrect object into the actionForm. I also deleted the line setting a collection object to the current session; that worked too. Anyway, your PROMPT response is much much appreciated.

By the way, I couldn't resist to scroll down and see your answers before trying it out myself. I was, say the least, a bit frustrated from trying for a long time before posting for help. Anyway, thanks again.
Consider Paul's rocket mass heater.
subject: Cannot find bean: "EMPLOYEELIST" in any scope
It's not a secret anymore!