SCBCD Guide
HomeSCJP | SCWCD | SCBCD | SCEA | SCSA

--------------------------------------------------
EXCEPTIONS
--------------------------------------------------
1. Calling remove twice on a bean results in java.rmi.NoSuchObjectException.
similarly, calling a business method on an already removed bean.

2. Invoking javax.ejb.EJBContext.getUserTransaction() in an entity bean instance method results in
java.lang.IllegalStateException because entity beans must always use container-managed transactions.

3. When the bean provider tries to reset the primary key value by means of a set method on any of the CMP
fields after it has been set in the ejbCreate method, it throws IllegalStateException.

4. EntityContext.getEJBObject() results in a java.lang.IllegalStateException when the entity bean does not define a
remote client view.

5. The container does not always throws a RemoteException when the tx is rolledback, but it MAY rollback
the tx when the remoteException occurs.

6. The Container MUST detect an attempt to assign a removed entity object as the value of a cmr-field of another
object (whether as an argument to a set accessor method or as an argument to a method of the
java.util.Collection API) and throw the java.lang.IllegalArgumentException.

7. If the argument to the set accessor method is NOT of the same type as the cmr-field, the container MUST
throw the java.lang.IllegalArgumentException.

8. Invoking javax.ejb.EJBObject.getPrimaryKey() on session beans throws RemoteException
Invoking javax.ejb.EJBLocalObject.getPrimaryKey() on session beans throws EJBException
Invoking javax.ejb.EJBHome.remove(java.lang.Object primaryKey) on session beans javax.ejb.RemoveException

9. If the container fails to start or commit a CMT, the container must throw RemoteException/EJBException
(For MDB- EJBException)

10. RemoteException/EJBException - indicates a failure to invoke an enterprise bean method or to properly
complete it's invocation.

11. If a client receive's RemoteException/EJBException, he can
(a) Discontinue Tx :- By calling rollback() or throwing a RuntimeException (if it's not the tx orginator)
(b) Continue Tx :- By first enquiring the tx status and then committing it.

12. In case of a CMT:-
If the bean method throws an application exception but does not mark the transaction for rollback,
the container will commit the transaction before re-throwing the application exception to the client.
If the bean method marks the transaction for rollback, the container will roll back the transaction
before re-throwing the application exception to the client.

13. If the Container denies a client access to a business method, the Container must throw
the java.rmi.RemoteException to the client if the client is a remote client, or
the javax.ejb.EJBException if the client is a local client.