1 Reply Latest reply on Aug 22, 2001 1:12 AM by Aaron Smith

    Stateful session bean concurrency issue

    Eric Newbie


      I am using a stateful session bean to represent a transient object on a server. This state of this bean is built up by a client. Eventually, this client tells the server to use this bean, by passing the bean as an argument to another (stateless) session bean. This second bean starts a new Thread and does some background work, which involves reading the state of the passed in stateful session bean.

      Unfortunately, since I am starting a new thread, the client can continue to use the bean as well, and this results in an Application Error stating that no concurrent calls on stateful session beans are allowed.

      The object is written to handle concurrent calls, but the container won't allow it. The question is: is this a requirement of the EJB spec, or might there be a way to allow this behavior via a change to my deployment descriptor?

      Thanks in advance for any help.


        • 1. Re: Stateful session bean concurrency issue
          Aaron Smith Newbie

          You are not allowed to spawn your own threads, hence the Application Error. This is mandated by the spec, so you won't find a work around via a deployment descriptor.

          Does the state need to be held in a Stateful Session Bean? You could store it in a local Java Object (stored in the users Session if you are using a Servlet Engine), and when ready, you could pass the Java Object (as a serialised object) to the processing Stateless Session Bean. You could then implement your own locking for the Java Object, which should be very simple (if the locking turns out to be complex, then maybe you need to take another look at your workflow).