File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Stateless bean removal 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 "Stateless bean removal" Watch "Stateless bean removal" New topic
Author

Stateless bean removal

George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
Hi all,
if client call remove() in home interface, will container call ejbRemove() in session bean? From HF EJB, ebjRemove should be called by container.
Please advise.. thanks.


SCJP, SCJD, SCWCD, SCBCD, SCEA, SCJP6
To be obtained: SCEA 5
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
in session bean it depends on if it is stateful or stateless.
1. stateful... it will call the remove
2. stateless... it will not call. The container is responsible for creation and removal.

if u look at the state diagram for the beans you will know if it is the result of the clients action or the container does it.
George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
If client call "remove()" in stateless bean, will ejbremoved() be called?
George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
Let me rephrase the question.
If client call "remove()" in home interface, what will happen?
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 130
George,
you will get RemoveException if you call remove() method forcefully. if your client is remote, then Container converts that RemoveException to RemoteException and throws it to the client.

Thanks,
Ugender
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
i am not sure if i will get an exception for calling a remove on a stateless session bean. all i could say is... i have called it in my session beans trial.. nothing will happen. the container will not actually bother abt the call it will neither give any exception nor call ejbRemove(). i dont have the HFEJB with me now but it is mentioned in that book in the session beans chapter.
can someone clarify about the exception... anyways how do i force a remove() call to a session bean in the first place?
Darien Cheung
Ranch Hand

Joined: Aug 13, 2004
Posts: 36
You will not get an exception for calling remove() on the EJBObject of a stateless bean. (spec p88) You are telling the container you are done with it but it is up to the container when it wants to destroy the bean (ejbRemove()). Instead, calling remove() will destroy the reference to the component interface. Any client that tries to use that same reference will get a NoSuchObject(Local)Exception.
Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
calling ejbRemove() behaviour doesnot change whether it is stateless or statefull Session Bean.
George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
From HFEJB p 550. It states "Stateless session bean clients will NEVER get a RemoveException.

So,whats' result when client call .remove() in stateless bean? it seems a tough question
Akila kamalanathan
Greenhorn

Joined: Jun 25, 2006
Posts: 3
Hi,
If you want to call remove method in the Home interface, it should have arguement. It is missing in your question.

The home interface(ie EJBHOME) has to method
1. remove(handle h)
2. remove(object o)

If you call the second one, you will get exception because its only for the entity bean.

For stateless session been, nothing will happen. The container only remove the beans to conserve the resources.
sai maddikay
Greenhorn

Joined: Jul 03, 2006
Posts: 14
I think when remove is called on a stateless session bean, the bean goes back to the pool created by the container. Now its upto the container to decide. if the container thinks that it is running low on resources, it might decide to reduce the pool size by removing the beans from the pool during which it will call ejbRemove() method for the corresponding bean instance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stateless bean removal
 
Similar Threads
When CMT bean commit?
Can a stateless session bean client call the remove()
When an EJBObject is created
Remote call or local call?
ejbRemove( ) Pls Help