You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Pringle <Ja...@captura.com> on 2001/04/05 20:29:08 UTC

RE: Frames, concurrency, and EJB Stateful Session beans - a probl em.

I think that's the way you'd want to go.  Essentially you're sharing the
reference to the EJB across mutliple threads, which kind of violates the "1
client - 1 instance" doctrine of stateful session beans (kind of in that
it's the same logical client, but two physical instances of client, if you
will).  You can have this same problem within multithreaded applications as
well.  If you wrap the reference within a javabean that synchonizes access,
and share this bean in session scope you should be ok.

-----Original Message-----
From: Abraham Kang [mailto:abrahamk@infogain.com]
Sent: Thursday, April 05, 2001 11:07 AM
To: struts-user@jakarta.apache.org
Subject: RE: Frames, concurrency, and EJB Stateful Session beans - a
problem.


Hi Bryan,

	Can you put the stateful session bean within a JavaBean with
synchronized
methods so that all access to the stateful session bean is through the
JavaBean?

--Abraham

> -----Original Message-----
> From: Bryan Field-Elliot [mailto:bryan_lists@netmeme.org]
> Sent: Thursday, April 05, 2001 8:09 AM
> To: struts-user@jakarta.apache.org
> Subject: Frames, concurrency, and EJB Stateful Session beans - a
> problem.
>
>
> I'm having a design problem with my system, which is not really Struts
> specific, but since there are a lot of EJB users here, I thought I'd
> throw it on this list for comments --
>
> My business logic is all implemented in a Stateful EJB Session bean. All
> Struts users get one instance of the session bean, whose reference is
> stored in the Servlet's Session scope.
>
> All of my Struts actions are simple; they take data from the user
> (usually in ActionForms), pass them to some method in the EJB Session
> bean, and store the results in beans for the JSP page to render.
>
> However, my design calls for a few places where there is a frameset, and
> in another place, where two browser windows open up showing two
> different views. The problem here, is that EJB requires that a Stateful
> Session bean have only one thread of execution within it (e.g. no
> concurrency). So, when two different Struts actions (or custom tags) try
> to invoke a method on the same EJB Session bean reference at the same
> time, one of them will fail with an exception thrown by the EJB
> container (in my case, jBoss).
>
> Can anyone recommend an easy, general-purpose solution to this problem?
> (Please don't say, "switch to stateless session beans"). I suppose I
> need to syncronize access to the EJB bean from the client (and, in this
> case, the client is Struts), but I'm not sure how to do this quickly and
> elegantly.
>
> Comments would be appreciated,
>
> Bryan
>
>
>