Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-171

Cannot store reference to a stateful session bean in the HTTP session

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • 7.0.0.Beta2
    • 7.0.0.Beta1
    • Web
    • None

    Description

      I have ported an application from AS 5/EAP 5.1 to AS 7 (a snapshot of Beta 2 actually), and in that application I am looking up a reference to a stateful session bean, to store it in the HTTP session, and the actual storage of the reference, gets the following:

      javax.servlet.ServletException: java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute sfsbOrderInquiry
      services.web.OrderInquiryServlet.doGet(OrderInquiryServlet.java:78)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      root cause

      java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute sfsbOrderInquiry
      org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1289)
      org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1250)
      org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
      services.web.OrderInquiryServlet.doGet(OrderInquiryServlet.java:74)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      It's saying that my attribute is not serializable, but the OrderInquiryBean in the lookup implements Serializable.

      The code in the servlet is as such, and it fails on the session.setAttribute("sfsbOrderInquiry", orderInquiry):

      HttpSession session = request.getSession();

      OrderInquiry orderInquiry = (OrderInquiry) session.getAttribute("sfsbOrderInquiry");

      if (orderInquiry == null) {

      InitialContext context = null;

      try

      { context = new InitialContext(); orderInquiry = (OrderInquiry) context.lookup("java:app/OrderManagerEJB/OrderInquiryBean!services.ejb.OrderInquiry"); session.setAttribute("sfsbOrderInquiry", orderInquiry); }

      catch(Exception lookupError)

      { logger.log(Level.ERROR, lookupError.getStackTrace().toString()); response.setStatus(500); throw new ServletException(lookupError); }

      }

      The top of OrderInquireBean looks like:

      @Stateful
      public class OrderInquiryBean implements OrderInquiry, Serializable {

      /** The serialVersionUID */
      private static final long serialVersionUID = -9113338082170911949L

      Attachments

        Activity

          People

            rmaucher Remy Maucherat
            rhn-engineering-anmiller Andrig Miller (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: