• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchEntityException & NoSuchobjectException confusion

 
Trupti Deo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When should the container throw NoSuchobjectException or NoSuchEntityException. The spec is little confusing in section 18.3.4.

As I understand, NoSuchEntityException should be thrown by Entity beans if the underlying entity has been removed from Database.

And NoSuchobjectException is should be thrown if the remove has been called prior to calling any method on the object.

Spec says in section 18.3.4: -

The NoSuchEntityException is a subclass of EJBException. If it is thrown by a method of an entity bean class, the Container must handle the exception using the rules for EJBException described in Sections 18.3.1, 18.3.2, and 18.3.3.
To give the client a better indication of the cause of the error, the Container should throw the java.rmi.NoSuchObjectException (which is a subclass of java.rmi.RemoteException) to a remote client, or the javax.ejb.NoSuchObjectLocalException to a local client.


Please help me understand.

Thanks,
Trupti
 
Ramakrishnan Viswanathan
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoSuchEntityException is an exception thrown by the bean to inform the container that the entity is missing. This can happen when the entity is removed (possibly by other means) from the persistent store.

If an attempt is made to invoke a method on an object that no longer exists, a NoSuchObjectLocalException or NoSuchObjectException will be thrown to the local or remote client respectively.

NoSuchEntityException is thrown by the bean to the container
NoSuchObject(Local)Exception is thrown by the container to the remote/local client
[ February 21, 2006: Message edited by: Ramakrishnan Viswanathan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic