could you provide some more information. It seems that you want to do something with MyBean on a session level. The reason you want a lock is that because of a using different winodws/frames or ajax requests?
Sometimes I get same exception mostly on ajax requests to my SFSB.
I've resolvet this by adding synchronisation to bean class.
@Name("myBeanAction") @Scope(ScopeType.SESSION) @Synchronized(timeout=10000)
Although the Seam documentation states that aceesing session scoped components are protected from concurerent access, I've found that adding Ajax requests sometimes makes it a bit more complex than you think.
You should try to solve this first at the source; meaning add a queue to your pages and if that not sufficient or doesn't work, start
synchronizingyour beans. Especially run-time errors in synchronised beans can give you a lot of headaches (I found that out myself....)
This is what I have in every page with forms/partial updates/rich components
<a4j:queue requestDelay="500" sizeExceededBehavior="dropNew" ignoreDupResponce="true" size="10" id="inputQueue" name="inputQueue" timeout="10000" />
All a4j:support tags, push etc. refer to this queue. Works for me !
Yes, this is right idea, also for
etc., try to add
Use same queue name for each request to this one SFSB, but this exception can be thrown in pure Seam ajax request for js/Seam remoting.
What about then? Only way is to catch concurrent requests by adding @Synchronised.
However, you can force a serialized threading model on any session bean or JavaBean component by adding the @Synchronized annotation.
This concurrency model means that AJAX clients can safely use volatile session and conversational state, without the need for any special work on the part of the developer.
Off course you should add @Synchronized when you're using Seam remoting, but
ajax page requestswith a queue saves you a lot of additional problems. The browser is not really a multi-threding wonder and I personally find debugging client side requests not the most exiting part of my job. ;-)