Look at the following from the ejb spec 1.1.  It specifically says clients are not allowed to make concurrent calls to a session object and that a remote exception is thrown if that happens.

6.5.6 Serializing session bean methods
A container serializes calls to each session bean instance. Most containers will support many instances
of a session bean executing concurrently; however, each instance sees only a serialized sequence of
method calls. Therefore, a session bean does not have to be coded as reentrant.
The container must serialize all the container-invoked callbacks (that is, the methods ejbPassivate,
beforeCompletion, and so on), and it must serialize these callbacks with the client-invoked busi-ness
method calls.
Clients are not allowed to make concurrent calls to a session object. If a client-invoked business method
is in progress on an instance when another client-invoked call, from the same or different client, arrives
at the same instance, the container must throw the java.rmi.RemoteException to the second cli-ent.
One implication of this rule is that it is illegal to make a �loopback� call to a session bean instance.
An example of a loopback call is when a client calls instance A, instance A calls instance B, and B calls
A. The loopback call attempt from B to A would result in the container throwing the
java.rmi.RemoteException to B.
Mark Cade wrote:

Dan,

  According to the EJB spec, it is the containers responsibility to synchronize
the calls to a stateful session bean.  The client does not have to enforce the
sychronization.  I have stored the handle to the session bean in the HttpSession
for the servlet and use the handle the get back to the session bean.  I have
not dealt with the Pet Store Demo, so I can't comment on that.

Mark
>I am confused about how to use EJB session beans from servlets.   Isn't
>is true that EJB session beans should only be accessed by one thread at
>a time and that the client must enforce that?  If that is the case then
>doesn't that mean that an EJB session bean should not be saved in a
>session object, since session objects can be accessed by more then one
>thread at a time. (I am referring to session objects in the servlet
>sense now, not the ejb sense.)   This happens when multiple windows are
>open or when frames are used.
>
>For example, it looks to me like the ejb session beans are saved in
>various session object of the Pet Store demo.  Doesn't this mean the
>demo is not thread safe?
>
>
>dan
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff EJB-INTEREST".  For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>

Reply via email to