• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

client calling remove() twice

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On page 559 of HFE it is said that


If client calls remove on a bean that's already removed, then the client gets RemoteException (remote client) or EJBException (local client).



But I think this is not true... when I tried (client calling remove() twice), I got java.rmi.NoSuchObjectException. This is said correctly in page 552 of HFE.

Then why this discrepancy ???
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Giju, you are right. As per the spec it should throw NoSuchObjectException.

So the statement is HFE is wrong.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Giju George:
On page 559 of HFE it is said that


But I think this is not true... when I tried (client calling remove() twice), I got java.rmi.NoSuchObjectException. This is said correctly in page 552 of HFE.

Then why this discrepancy ???



If...
- Container had removed the session bean because the bean had either thrown a system exception
or timed out.

And...
- Client still has a reference to the bean (via the remote component and a live stub) and invokes
a method.

Then...
- NoSuchObjectException will be thrown.


If...
- Client invokes remove(Object primaryKey) on a session bean - session beans do not have primary keys.

OR

- Session bean instance is participating in a transaction and the client invokes the
remove method on the session object�s home or component interface object.

Then...
RemoveException will be thrown
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



If...
- Client invokes remove(Object primaryKey) on a session bean - session beans do not have primary keys.

OR

- Session bean instance is participating in a transaction and the client invokes the
remove method on the session object�s home or component interface object.

Then...
RemoveException will be thrown



These two scenarios are considered separately in pages 558 and 559.

"Client calls remove() on a stateful bean that is still in an open tx"

"Client call the home remove method on the home interface of a session bean"

In both scenarios the book says you get a RemoveException as Keerthi points out. That's fine.

The other scenario, the one Giju is talking about, says "Client calls remove() on a bean that's already been removed"

I agre with Giju in that in this case you should get a NoSuchObjectException, specially when the book says "remove() is just another method in the bean's interface ... you'll get the same exception you'd see if you called any other business method on a removed bean". So we're not talking about removes in the home interface and calling remove within an open transaction is also considered separately. The only choice here has to be NoSuchObjectException ...

So can we say the book is wrong??
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NoSuchObjectException is a RemoteException. :roll:
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Jason....
I forgot that NoSuchObjectException is a subclass of RemoteException.

But my ques is .. what does the client get, RemoteException/ NoSuchObjectException ?. Because if the bean throws a system exception, then the container will throw a RemoteException to the (remote)client. Does that mean the client can get any subclass exception of RemoteException ?
 
Are you here to take over the surface world? Because this tiny ad will stop you!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic