Struts - Cannot find bean in any scope

28.5k Views Asked by At

I'm using eclipse to implement with the native Struts and hybernate support an application to display a series of links in a page. I'm getting the error:

javax.servlet.jsp.JspException: Cannot find bean: "ListeActeur" in scope: "session"

I've checked a lot of sites and forums, and nothing seems to fix this.

My struts-config:

<struts-config>
<form-beans type="org.apache.struts.action.ActionFormBean">
  <form-bean name="ListeActeur" type="mesForms.strust.ListeActeur"/>
  <form-bean name="vérifCritère" type="mesForms.strust.vérifCritère"/>
</form-beans>
<action-mapping>
    </action>   
    <action path="/Liste" 
    parameter="/vue/Invitation.jsp"
    name="ListeActeur     scope="request       validate="false"
                     type="mesAction.struts.ListeActeurAction">  
    <forward name="s" path="/vue/NewFile.jsp" redirect="false" /> 
    </action>
</action-mappings>
</struts-config>

ListeActeurAction:

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest req, HttpServletResponse res) throws Exception {
        System.out.println("Action");

        ListeActeur ListeActeur= (ListeActeur) form;
        String query = "select * from Acteur " ;

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
         Iterator results = session.createSQLQuery(query).list().iterator();
         List <Acteur> lis = new ArrayList<Acteur>();
         while((results.hasNext()))
         {
             Acteur gg =new Acteur();
            Object[] row = (Object[]) results.next();
            gg.setActeurId((Integer)row[0]);
            gg.setNomActeur((String)row[2]);

             lis.add(gg);
         }
         req.getSession(true).setAttribute("lis", lis);
         session.getTransaction().commit();
         HibernateUtil.getSessionFactory().close();             
        ListeActeur.setLis( lis);
        req.setAttribute("formu", ListeActeur.getLis());

        return mapping.findForward("s");
        }
}

ListeActeur:

public class ListeActeur extends ActionForm {

private  List <Acteur> lis=null;

public List <Acteur> getLis(){
    return lis;}
public void setLis(List <Acteur> lis){this.lis=lis;}
public void reset(ActionMapping mapping, HttpServletRequest request) { 

    lis = new ArrayList<Acteur>();  
}

I really dont know what to do. Im a newbie in Struts.Thanks in advance!

1

There are 1 best solutions below

4
On

You have

<action path="/Liste" scope="request" .../>

and

<logic:iterate ... scope="session" >

no wonder you get this exception. If you configure Struts to store the form bean in the request, don't try to fetch it from the session in your JSP.