• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Home object stub and EJB object stub

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
parra matta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic