File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Some basic doubts on session beans... 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 "Some basic doubts on session beans..." Watch "Some basic doubts on session beans..." New topic

Some basic doubts on session beans...

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
I am having some basic doubts on session beans, please clarify them ( I know they are very silly for you)

1. What will happen if the user calls remove() method on stateless session bean ?

2. What will happen if the user is not calling any of the methods for long time, when the statefull session bean is in method ready state.
==> My understanding is - If the method is in the transaction and the user is not interacting for the specified time( defined by the container), then ejbRemove() method is called and the bean moves to 'does not exist' state.
If the method is not in the trasaction, first the bean is moved to passivate state and even after moving to the passivate state user is not calling any methods, then the bean is moved to 'does not exist' state, with out calling, ejbRemove() method -
Is this correct or not? If it is not, then please correct me

3. How can we get the transaction reference in ejbPassivate()/ejbActivate() methods -- Bec, ejbPassivate() is called only if the bean is not in the transaction. Now, if the bean is not in the transaction, how will you get the transaction references???

4. In setSeesingContext(), why can't i get the reference to the EJBObject()? Bec, EJB Object is created before creating the session context.

5. Will ejbRemove() is called, if user calles the remove() method and the bean is already passivated, i.e. bean is in passivated state.


Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
1) The container ignores the remove request
2) The bean will NEVER be passivated or removed if it is in a transaction, no matter how long it has been since the client called a method. The container might call ejbRemove first, instead of calling ejbPassivate. You're right, if the bean is passivated, the container will not call ejbRemove.

Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
I agree. Here's the link:
subject: Some basic doubts on session beans...
It's not a secret anymore!