0 Replies Latest reply on Jul 4, 2005 4:11 AM by Tolga Tarhan

    javax.persistence.EntityNotFoundException gets wrapped in ja

    Tolga Tarhan Newbie

      If you have session bean methods which throw javax.persistence.EntityNotFoundException (which seems like a reasonable exception to throw), the EJB container in Beta 1 automatically wraps these in a javax.ejb.EJBException.

      The specification, however, says "If problems are encountered at the protocol level, an EJBException which wraps the underlying RemoteException is thrown by the container."

      The core specification also says: "...as an indication of a failure to invoke an enterprise bean method or to properly complete its invocation... If the client receives the javax.ejb.EJBException or the java.rmi.RemoteException
      exception from a method invocation, the client, in general, does not know if the enterprise bean?s method has been completed or not."

      Clearly not true in this case -- there was no comm problem and there was no problem with the business method itself. Just a missing entity.

      It seems much more useful and specification compliant to treat EntityNotFound as an application exception, which the specification specifically requires to be returned to the client unwrapped.