• 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

mock exam from HF pg 242

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on pg 242 HF, question 5

If a client makes a call to a session object that has been removed by the container, which exceptions can be thrown:

1. java.rmi.RemoteException
2. ...RemoveException
3 ... NoSuchObjectException
4. ... NoSuchEntityException
5. ...ObjectNotFoundException

According to me answer 3 is correct, but the response from Kathy&Bert is 1 and 3. Could anybody explain why 1 is also correct? I have also checked the erata...

I know that NoSuchObjectException extends from RemoteException. But doesn't the container garantee that always a NoSuchObjectException is thrown?

Miki
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quote from the EJB spec:

If a client makes a call to a stateful session or entity object that has been removed, the container should throw the java.rmi.NoSuchObjectException (which is a subclass of java.rmi.RemoteException) to a remote client


As it is not guaranteed that NoSuchObjectException will be thrown, the answer in the book is correct.
 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roger, could you please note the page in the spec since I can not find that formulation you just gave.

The only thing I can find is on pg. 379 (18.3.5), which says:

if a client makes a call to a session object that has been removed the container should throw the java.rmi.NoSuchObjectException ...

.

But it doesn't say that by default it throws a java.rmi.RemoteException, and that would be better to ("should") throw a NoSuchObjectException. Wheras in section 18.3.4 the distinction between what the container has to do and what it should do is clearly highlighted.

Miki
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RemoteException is always thrown to a remote client, the spec is encouraging - but not requiring - the container to be helpful to the client by throwing a subclass (NoSuchObjectException) in some cases. As NoSuchObjectException or RemoteException will be thrown, the book's answer is correct.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roger,

You mean to say that we need to look for the Local Interfaces in the same way,like we should look for javax.ejb.EJBException if the client makes a call to the session object that is being removed.

Iam using the same logic for local interfaces

Regards
Shiv
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same principle applies for both local and remote clients. If a local client makes a call to a session object that has been removed, the Container should throw javax.ejb.NoSuchObjectLocalException or javax.ejb.EJBException to the client. You therefore must code your local client to handle both exceptions.
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Roger...its also in HFEJB ..pg.550 in Exceptions chap. Second "Bang" ---The Client mite NOT get the most specific exception.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic