• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on stateful session beans  RSS feed

 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This time I've got a question on stateful session beans. I read that when a stateful session bean instance is executing a method for a client, if some other client tries to invoke a method on the same stateful bean instance, the client gets an exception.My question is how is this scenario ever possible? A stateful session bean is supposed to be dedicated to each client. Is it not the container's responsibility to assign a unique bean instance to each client that does a home.create() ? How can 2 clients ever get the same stateful bean instance? How is this scenario ever possible for a stateful session bean?
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think they are more concerned about multiple threads of the same client trying to access the same SFSB instance. However you could probably serialize the handle, send it to other client(s) over the network - unless a business method is currently in progress the container would have no idea whether the original client is going to use the SFSB instance again.
EJB 2.0 Specofication p.76
7.5.6 Serializing session bean methods
...
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[4], 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.
 
Mani Venkatachalam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have experienced this problem before. I get an exception when i double click the submit button from the form which basically going to call a method in a session bean. Would session bean consider double click as two different client requests?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!