• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

NoSuchEntityException & NoSuchobjectException confusion

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic