2 Replies Latest reply on Mar 29, 2006 4:20 AM by spayeur

    Value for the useBean class attribute is invalid -- why?

    monocongo

      I have a JSP which when called gives the following error:

      11:27:07,135 ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
      org.apache.jasper.JasperException: /useractivity/UserActivitiesDisplayAndUpdate.jsp(9,0) The value for the useBean class attribute com.mycom.grover.bean.UserActivity is invalid.
      


      In the servlet which directly precedes the JSP I have set an object of this class into the HttpSession as an attribute, like so:

      if (userActivity != null)
       {
       // add the bean to the session
       request.getSession().setAttribute("userActivity", userActivity);
       }
      
       // redirect the request
       response.sendRedirect(m_nextPage);
      


      In the JSP I want to use the object as a bean so instead of using session.getAttribute() I use jsp:useBean, like so:

      <jsp:useBean id="userActivity"
       class="com.mycom.grover.bean.UserActivity"
       scope="session"/>
      
      


      Am I mistaken in assuming that I can do this?

      Can someone tell me what I'm doing wrong?


      --James

        • 1. Re: Value for the useBean class attribute is invalid -- why?
          monocongo

          The problem was that the class was missing a no-args constructor, and hence wasn't a valid JavaBean.

          --James

          • 2. Re: Value for the useBean class attribute is invalid -- why?
            spayeur

            Getting the same error, but I've got a default constructor...
            org.apache.jasper.JasperException: /index3.jsp(497,0) The value for the useBean class attribute forum.GetChildMessages is invalid.

            Setting errorOnUseBeanInvalidClassAttribute to false yields a ClassNotFoundException.


            ---- GetChildMessages.java ----
            ...
            public class GetChildMessages implements Serializable {
            private int parentid;
            public GetChildMessages() {
            parentid = 0;
            }
            ...

            ---- index3.jsp ----
            ...
            <jsp:useBean id="gmk" class="forum.GetChildMessages" scope="request" >
            ...

            Used to work in Tomcat 4.1, but I'm now
            using Tomcat 5.0.28, Apache 2.0.43, Win 2000.