• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Bean Handle question

 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if getEJBObject() is called on a Handle, but the bean has been removed by the container due to time-out? Let us assume that the Handle is able to establish a connection to the server successfully.

HFEJB, Pg: 140 says that a RemoteException will be thrown.

My understanding from the spec is that java.rmi.NoSuchObjectException (and NOT RemoteException) will be thrown.

Am I right?
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keerthi P:
What happens if getEJBObject() is called on a Handle, but the bean has been removed by the container due to time-out? Let us assume that the Handle is able to establish a connection to the server successfully.

HFEJB, Pg: 140 says that a RemoteException will be thrown.

My understanding from the spec is that java.rmi.NoSuchObjectException (and NOT RemoteException) will be thrown.

Am I right?


I believe that java.rmi.NoSuchObjectException (or javax.ejb.NoSuchObjectLocalException if the client is local) would be thrown if a client would invoke a method on the EJBObject stub and the underlying object couldn't serve the purpose. In the case of a getEJBObject
on a Handle, I believe that java.rmi.RemoteException would be thrown by the container.

My 2 cents.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy! The NoSuchObjectException is normally what you'd get when you invoke a method on a *stub* object and the Remote object the stub was a proxy for is not available.

But Handles are not stubs... they're just Java objects that somehow know (it's up to the Container provider to implement the Handle class however it wants to) how to connect back to the server and retrieve a stub that is *functionally* identical to the original stub from which the Handle was retreived.

So, since the Handle is not a stub, you're not making a *traditional* RMI Remote method invocation on the Handle, even though the Handle is certainly going to be making a network call, so that's why the RemoteException makes sense... "Something went wrong with the Remote part of this method..."

Hope that helps. We should have explained that better.

cheers,
Kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic