|
Session Beans Constraints
|
|
-
Session beans disappear from the server, if
-
The session bean’s timeout value expires
-
The server crashes and is restarted
-
The server is shutdown and restarted
-
If any of these event occurs, state information of the bean is lost.
Solutions:
-
Session timeout value is configurable so the timeout value can be increased.
-
Server crashes and restarts are fairly rare events.
-
The user can be notified that non-recoverable error has occurred and ask the user to try again later.
-
A copy of the state of the bean can be cached at the client side and a new bean can be recreated in the event of original bean dies.
-
Use a database on the server side to hold the state of the client’s conversation. If the session bean dies during the conversation, the client can reconnect and pass in a unique customer identifier to query the database to retrieve whatever state information was saved prior to the failure of the session beans.
Solution:
-
A stateless session bean cannot implement the SessionSynchronization interface. Because stateless session beans lack a conversational state and cannot hold a transaction across method invocations.
-
The final constraint on session beans is that they are not reentrant. If one thread is currently using a session bean, the container will throw a java.rmi.RemoteException in response to any other requests to connect to the session bean.
|