aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can a stateless session bean be removed by client? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can a stateless session bean be removed by client?" Watch "Can a stateless session bean be removed by client?" New topic
Author

Can a stateless session bean be removed by client?

Mellon Sun
Ranch Hand

Joined: Feb 20, 2003
Posts: 126
EJB Core Contracts and Requirements, Page 42:

A client may remove a stateful session bean by invoking a method of its business interface designated as a Remove method.

The lifecycle of a stateless session bean does not require that it be removed by the client. Removal of a stateless session bean instance is performed by the container, transparently to the client.

"The lifecycle of a stateless session bean does not require that it be removed by the client." I cannot understand this sentence, I suppose it want to tell stateless session bean can or cannot be removed by the client. However, it looks like the most important word "can" or "cannot" is lost.


SCJP,SCWCD1.3,SCWCD1.4,SCJD,SCBCD5,SCEA5
Piotr Uryga
Ranch Hand

Joined: May 25, 2006
Posts: 68
What would be the purpose of removing stateless session bean by client?
These beans aren't connected to clients between method calls. They are... well stateless.
Immediately after being used by client SLSB is returned to pool of SLSB's and the rest is up to container.


SCJP 1.4, SCWCD 1.4, SCBCD 5, SCEA
Meherdad Bomanbehram
Ranch Hand

Joined: May 28, 2007
Posts: 132

In one word , NO
Stateless sessions beans are sent back to the bean pool between method calls as they are not tied to any pone client every time a client calls a method on a SLSB the container randomly selects one from the bean pool and associates it with a client passing its reference to the client .
Hence as SLSB are are only removed from the pool when the server/container sees it fit to do so , which is when its low on resources or depending on the timeout setting of the server specific xml discriptor file (basically it is server specific) , and never by the client on calling remove or any other method . It may also be removed if during a method call an exception occours from which the bean is not able to recover.
LakshmiNarayana Kodali
Greenhorn

Joined: Oct 30, 2008
Posts: 16
Client cannot remove Stateless Session Bean.

Only the Container can remove the Stateless Session Bean.

The following are the cases where the Stateless Session Bean will be destroyed.

1. If the Container finds that thee are already more beans in the pool, then there is possibility that few beans will be removed.
If there is any @PreDestroy method, it will be called first and then destroyed

2. If Container crashes, then beans will be removed without calling @PreDestroy method
[ December 12, 2008: Message edited by: LakshmiNarayana Kodali ]
 
 
subject: Can a stateless session bean be removed by client?