This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Author

Home object stub and EJB object stub

parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Hi,

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?

Thanks.
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.

Thanks.
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 130
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.

Thanks,
Ugender
Charlie A
Greenhorn

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."
 
Don't get me started about those stupid light bulbs.
 
subject: Home object stub and EJB object stub
 
Similar Threads
ProtableRemoteObject.narrow()
EJBHome & Bean
Access EJB from different EAR
remote reference
Chapter 2 - HF Sark study group