This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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,
Alex (SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCJD 1.4)
Joined: Aug 05, 2003
ok. didn't see this in the books... still...
i thought the stateful session bean instance is serving one client only. the client which state is actually kept. how comes another client can call the same bean?
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.
Joined: Aug 05, 2003
well, such request won't be simultanious.. ok, thanks a lot for replies.
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.