Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock exam from HF pg 242

 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
ShivPrakash Srivastava
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic