2 Replies Latest reply on May 14, 2003 3:04 PM by tkitz

    Need urgent help: how to avoid concurrent calls on statefull



      I need a little advice in designing a EJB session facade using JSPs, servlets, session and
      entity beans.

      My current design is:

      - JSP pages: here are only getMethods for the session bean used. All set-methods are handled by a
      - servlet: I have got one servlet handling several JSP pages. The servlet basically takes the
      form fields and stores them in the session bean and than dispatches to the next JSP-page
      - stateful session bean: here is, where all the business logic is conducted. There is one session
      bean per servlet using several
      - CMP entity beans: to talk to the database (Oracle 8i)

      The application server is JBoss 3.0.3.

      My problem is, if a user clicks on a submit button of a JSP page more than once before the next
      page builds up, I may get a "javax.ejb.EJBException: Application Error: no concurrent calls on
      stateful beans" error. I already synchronized (by the "session") the code in the servlet, but
      it happens in the JSP pages as well.

      I know, that Weblogic is able to handle concurrent calls, by JBoss isn't and it's clearly stated
      in the spec, that a user should avoid to have concurrent calls to a stateful bean.

      The big question is now: How can I avoid this? How can I prohibit the user to submit a form several
      times or to ignore anything, which arrives after the first submit?

      Thanks for any help,


        • 1. Re: Need urgent help: how to avoid concurrent calls on state
          Jon Barnett Master

          Can you set up a session flip-flop to stop double bounce? That is, toggle a servlet session variable to indicate that the form has been submitted and clear it when you complete the form submission? Check the variable before allowing submission. Is that sufficient for your needs?

          • 2. Re: Need urgent help: how to avoid concurrent calls on state


            thanks for your suggestion, which is partly working. I put the flip-flop routine on the top of the service method of the servlet and release the lock at the end of each JSP page. The routine at the top of the method is

            // Servlet Toggle on
            if ((session.getAttribute("cAHDServletToggle") != null) && (session.getAttribute("cAHDServletToggle").equals("t"))) {
            // subsequent calls
            } else {
            // first call

            The problem now is, when a user hits the submit button twice, the service method is called the second time, runs into the first part of the if-statement and returns. At that stage, the first request is suspended and no output is made through Tomcat, which is maybe better than an error message, but not what I had in mind :-)). Any ideas how to handle this problem?