we are to develop application and we are investigating
BEA WebLogic 5.1. We tried to call statefull session bean
from two threads simultaneously and got error:
Does somebody knows how Container should serialise
calls to session beans? How to tune the timeout?
let me explain what the problem is:
when thread one calls a method on the session bean
a transaction will be started (depends on the deployment descriptor) and during the transaction the session bean is "locked".
therefore it is impossible for thread two to
access the session bean at the same time.
the question is how can you solve this problem?
we have solved the problem in the following way:
create a helper class that encapsulates the session bean.
this class acts as a fasade controller to the session bean.
it delegates method calls to the session bean:
public class Helper
public void operation()
the getBusyFlag() tries to get a lock. if it fails
it will call wait() and wait until notifiy() is called.
perhaps someone found a better solution?
Did it actually wait for 300 seconds (default timeout)? I think (I might be wrong though) that container is supposed to throw RemoteException immediately when you try to access the bean instance which is executing a business method.
This is illegal. Concurrent access to a single bean is not allowed in EJB. According to the spec, the container should throw InvalidTransaction not a locking error.
Some app serverfs like EAServer do allow for a semaphore to syncrhonize access to these objects, but, it is not portable. The container is supposed to throw an exception.
You might control access via a facade if possible
Internet Applications Division