there is a living stateFUL bean in the middle of the business method.
a new client request arrives but the bean is not done yet with the request that arrived earlier. what happens?
what would you say?
Severin has correctly identified the exceptions that will be thrown to the second client.
The question is about concurrent access to an instance of a stateful session bean. That is what the spec says about such access (section 7.5.6) :
Clients are not allowed to make concurrent calls to a stateful 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 of a stateful session bean class, the container may throw the java.rmi.RemoteException to the second client, if the client is a remote client, or the javax.ejb.EJBException, if the client is a local client. This restriction does not apply to a stateless session bean because the container routes each request to a different instance of the session bean class.
Hope it helps,
how comes another client can call the same bean?
I could pass the Handle or the reference to some other class/application which could then invoke methods on the bean.
Some containers like Weblogic 6.1 do not throw RemoteException but queue the client request but this could be configured in vendor specific DD to throw RemoteException.
Hope this helps.
If you want to test this what you can do is write a servlet.In that servlet first check if instance of stateful session bean exists as session attribute and if yes use it or else create new instance and store it in session. Once you get instance of bean call methods on it.
After deploying this servlet try to refresh the page calling servlet repetadly so that it gets multiple requests.
well, such request won't be simultanious..
They are simultaneous requests,so you get the Exception. Client 1 could get a Handle to SFSB and write it some secondary storage. Client 2 could read the handle from the storage, then both client1 and client2 could be making simulatnoeus requests to the stateful session bean, since both them have handle to the same session bean.