aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark ""NoSuchEntityException" vs "NoSuchObjectException" -- HFBook ,p.563" Watch ""NoSuchEntityException" vs "NoSuchObjectException" -- HFBook ,p.563" New topic
Author

"NoSuchEntityException" vs "NoSuchObjectException" -- HFBook ,p.563

Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
Dear All,

In HFBook ,p.563, #2:

Which scenario will cause a java.rmi.NoSuchObjectException to be thrown ? (Choose all that apply)


A.
A remote client invokes a method on a stateful session bean which has been removed.

B.
A remote client invokes a method on an entity bean which has been removed.

Answer is A & B.

I agree the ans is A. But I don't understand by B is also correct.
As far as I know:

1. entity bean don't have remote interface, what's the "remote client invokes a method on an entity bean" means ? Is it RemoteClient --> Session Bean --(locally called)--> entity bean.

2. Refer to ans B, why "NoSuchEntityException" will not be thrown ? (since during the method execution, the entity bean may be removed by admin way, refer to HFBook P.552, point 4).

3. Refer to entity bean, what's the different between "NoSuchEntityException" and "NoSuchObjectException" ?
I. NoSuchObjectException - A stub call a corrupted / no longer invalid EJBObject.
II. NoSuchEntityException - Called Entity is no longer in the database.

Seems point II can be the reason of point I, I can't see the difference between 2.

thanks !


Vince Hon<br /> <br />SCJP 1.4 | SCWCD | SCBCD <br /><a href="http://vincehon.homeip.net:8000/VJW" target="_blank" rel="nofollow">http://vincehon.homeip.net:8000/VJW</a>
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
#########################################################################
As far as I know:

1. entity bean don't have remote interface, what's the "remote client invokes a method on an entity bean" means ? Is it RemoteClient --> Session Bean --(locally called)--> entity bean.

#########################################################################

First of all entity beans can have remote interfaces. If the session bean or the entity bean is removed and the client tries to invoke a method then
NoSuchObjectException will be thrown.

NoSuchEntityException will be thrown when the entity is not there in the persistent storage. Suppose you have a database with the table having customer information and someone using database admin tool deleted the entry of a specific customer for which you are calling the method on the entity bean. In this case the NoSuchEntityException will be thorwn.

Hope that helps


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
thx sawan.

Let me clarify if my concept is correct:

NoSuchEntityException will be thrown when the entity is not there in the persistent storage.


If I change that statement to:
1.
A remote client invokes a method on an entity bean which *its persistent storage has been deleted by other means*.
--> Is it possible the client recieve "NoSuchObjectException" (Since "NoSuchEntityException" is for local client only) ?
In this case, the bean should throw "NoSuchEntityException", the container catch it and rethrow as "NoSuchObjectException" to the client, am I correct ?

2.
A *LOCAL* client invokes a method on an entity bean which *its persistent storage has been deleted by other means*.
--> Will the local client recieve "NoSuchObjectLocalException" or "NoSuchEntityException" ?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Vince Hon:

In this case [for Remote], the bean should throw "NoSuchEntityException", the container catch it and rethrow as "NoSuchObjectException" to the client, am I correct ?

Yes.

2.
A *LOCAL* client invokes a method on an entity bean which *its persistent storage has been deleted by other means*.
--> Will the local client recieve "NoSuchObjectLocalException" or "NoSuchEntityException" ?

The client receives NoSuchObjectLocalException.

See section 18.3.4 on page 379 of the spec.
[ April 14, 2005: Message edited by: Marc Peabody ]

A good workman is known by his tools.
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884

Is it possible the client recieve "NoSuchObjectException" (Since "NoSuchEntityException" is for local client only) ?


Where did you get that idea that NoSuchEntityException is meant for local client only? It is actually an exception thrown by the bean to inform the container that the entity is missing. (Refer to HFEJB, page 552)


A *LOCAL* client invokes a method on an entity bean which *its persistent storage has been deleted by other means*.
--> Will the local client recieve "NoSuchObjectLocalException" or "NoSuchEntityException" ?


The client doesn't get to "see" the NoSuchEntityException. Its thrown by the bean to the container. The container throws NoSuchObject(Local)Exception to the client.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Vince Hon
Ranch Hand

Joined: Feb 11, 2003
Posts: 117
Thanks Chengwai and Marc !

I have a clear concept now.
The reason of I get confused because I misunderstood the exception throwing pathway:
Bean --> Container (NoSuchEntityException)
and
Container --> Client (NoSuchObject(Local)Exception)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "NoSuchEntityException" vs "NoSuchObjectException" -- HFBook ,p.563
 
Similar Threads
NoSuchEntityException
NamingException
Exceptions
NoSuchEntityException & NoSuchobjectException confusion
Thorwn Exception of local