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 Home object stub and EJB object stub Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Home object stub and EJB object stub" Watch "Home object stub and EJB object stub" New topic

Home object stub and EJB object stub

parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40

On page 109 of HFEJB, it claims that the Home object stub and EJB object stub do not exist on the server. But if they do not exist, how can they be returned to the client?

Are they created on the server and returned to the client and then garbage collected?

Joy Mookerji
Ranch Hand

Joined: Jul 26, 2006
Posts: 49
When you deploy the ejb the container generates the stub classes for you and also creates the classes that implements the EJBHome and EJBObject.
These are proxy classes (Proxy pattern) and has code to communicate(marshalling and unmarshalling) with the corresponding EJBObject and EJBHome classes.
So during run time when a client make a call to the proxy object it communicates with the cooreponding Remote EJBObject and EJBHome to transfer the call.
When you remove the Bean by calling remove on the EjbObject or home interface the Bean is destroyed (Stateful Session Bean) the EJBObject is destroyed and they are ready for garbage collection.
However there is no gurantee that the corresponding stub and home stub is also destroyed in the client but if you try to call methods on them you will get
java.rmi.NoSuchObjectException(Remote) javax.ejb.NoSuchObjectLocalException

SCJP 5<br />Brainbench Certified in C++<br />PMP<br />Dallas,TX
parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Yes, you are right. My question is partially answered.

According to the spec, when you call create on the Home stub, it will eventually return a EJB Object stub to you. I would imagine that the Home object on the server creates the EJB object stub and sends it to the client. So why the HFEJB claims that the EJB object stub as well as Home object stub do not exist on the server? They exist at least until they are sent to client.

Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 135
parra matta,

" EJB object stub as well as Home object stub " are created by the Container so you really not sure wether it kept them alive or not. I guess this is vendor specific. But this two stubs wont relate any way with the bean in the server. So when you call remove, you are removing the bean instance on server side not the stubs.

Please feel free to add any comments.

Charlie A

Joined: Apr 17, 2005
Posts: 19
Yes.. Ugender is absolutely correct ..
EJB Spec just expects the container to return the Home/Remote Object stub to the client, it is upto the container vendor how they deal with this.

When the world says, "Give up,"<br />Hope whispers, "Try it one more time."
I agree. Here's the link:
subject: Home object stub and EJB object stub
It's not a secret anymore!