Problem with stateful session bean (URGENT)

Discussions

EJB programming & troubleshooting: Problem with stateful session bean (URGENT)

  1. Hi

    I am using bea weblogic 6.0 as application server.
    I am having a problem with Stateful session bean. Error message got is

    "Remote Exception EXCEPTION OCCURRED :: Stateful session beans cannot be used concurrently. "

    Can anyone explain me why this would arise and how can this be avoided. I dont know unedr what circumstances this would happen , can anyone please give me an example (of course not code)

    Awaiting reply
    Thanks
    pranav
  2. I'm not 100% sure, but I guess you are accessing the same session bean from two different threads concurrently.
    Accorsing to the EJB specs it is illegal to access a SFSB concurrently, and this is what you are doing it seems.
    Check whether you have this situation:
    1) retrieveing reference to a SFSB (create())
    2) Saving it somewhere
    3) Starting another thread and accessing it from both threads

    kind regards

    Messi
  3. There is an attribute called "ALLOW CONCURRENT CALLS" (you will have to look it up in the Weblogic documentation) that lets Statefull session beans play well together in Weblogic 6. We had the same problem and solved it with this added attribute in the weblogic descriptor file. Changing the session bean to stateless would also solve this problem. Just a hunch.

    Kent
  4. Setting the bean to allow conncurrent calls will surely make the symptoms go away but does not address the problem.

    Why does the bean have concurrent clients? Is it:

    1) A servlet storing the stub in an instance variable?
    Instance variables in servlets are bad news, instead use a method temporary in the service or doXXX method if the bean is only needed for the request. Store the stub into the HttpSession if the session bean needs to span HTTP requests.

    2) Is it a JSP that has a field declaration (<%!) storing the stub? (same problem as 1)

    3) If it is a standalone application are you using multiple threads?

    Stephen