-
1. Re: How to avoid concurrent calls to stateful session beans?
petertje Feb 28, 2003 5:58 AM (in response to tkitz)> I understand from reading in these forums,
> that concurrent calls are a nono for statefull
> session beans, but how can I avoid them in a web
> application? Is there an easy way to prohibit the
> servlet to call the session bean more than once?
What about something like
[pre]synchronized (session) {
ejbAHD.whatever();
}[/pre]
Peter -
2. Re: How to avoid concurrent calls to stateful session beans?
tkitz Mar 2, 2003 12:08 PM (in response to tkitz)Hi Peter,
> What about something like
> [pre]synchronized (session) {
> ejbAHD.whatever();
> }[/pre]
thanks for the tip. It works great for the servlet part, but I still have problems accessing the bean properties on the JSP side. I tried to put the synchronizd block around the whole JSP code, but Tomcat seems to ignore that during compilation time. Also doing something like<%= synchronize (session) { ejbAHD.getMyProperty() } %>
doesn't work either. I get the concurrent error message only sometimes during the first time compilation of the JSP page when I hit the same button several times, which maybe because after that the response of my system is too fast, but I don't want to take any risks in production.
Thanks,
Thorsten. -
3. Re: How to avoid concurrent calls to stateful session beans?
joelvogt Mar 3, 2003 5:14 PM (in response to tkitz)A good way to do this is to move all your ejb calls out of your servlet. Have your servlet use another class that will access to and from your model layer. Then make the methods on this synchronized so that you will only get one call though at a time.