I think whether client get RemoteException is not determined by client implement Remote or not,is determined by if the business method is remote and did it implement Remote interface(please reference master ejb3 eppendix E,too long to refer here)
But in some of the books it says that the container wraps the exception into RemoteException for remote clients.
Joined: May 15, 2005
Read the specs
1. For MDB, Other beans it throws javax.ejb.EJBException 2. For webservice client it throws javax.rmi.RemoteException 3. For EJB 2.1 Client throws RemoteException if its remote client throws EJBException if its local client 4. Throws EJB 3.0 Client If the remote extends java.rmi.REMOTE remote exception in thrown.
Joined: May 15, 2005
If bean method runs in the transaction started by the container[Required or Require New]
If any application exception is raised
Containers Action 1. Should rethrow the app exception 2. If instance calls setRollBack, then rollback or do rollback depending up @ApplicationAnnotation type & rethrow the exception.
Client View 1. Receive application exception 1. If the client executes in a transaction, the client transaction is not marked for roll back
Would the transaction is still not marked for rollback if the client initiated the transaction. I mean if the client had initiated, the transaction would have been propogated to the bean method[In case of Required].
The exception chart in the spec is a bit confusing.
hi i read from Manning book EJB 3 in Action page 88 about the Remote business interface.
A remote business interface may extend java.rmi.Remote as we�ve done here, although this is optional. Typically the container will perform byte-code enhancements during deployment to extend java.rmi.Remote if your bean interface does not extend it. Remote business interface methods are not required to throw java.rmi.RemoteException unless the business interface extends the java.rmi.Remote interface.
Is that mean if I explicit extends the Remote business interface with java.rmi.RemoteExcepton , client will get RemoteException instead of EJBException ? [ July 04, 2008: Message edited by: Witt Lilavivat ]
System exceptions include java.lang.RuntimeException and its subclasses. EJBException is a subclass of RuntimeException, so it is considered a system exception. System exceptions also include java.rmi.RemoteException and its subclasses. The RuntimeException and RemoteException subclasses differ in that they can be turned into application exceptions using the @javax.ejb.ApplicationException annotation.
Later in the same chapter (page 399):
In session beans, when a system exception occurs and the instance is discarded, a RuntimeException is always thrown whether the client is a remote or local invocation. If the client started the transaction, which was then propagated to the EJB, a system exception (thrown by the enterprise bean method) will be caught by the container and rethrown as a javax.ejb.EJBTransactionRolledbackException. EJBTransactionRolledbackException is a subtype of RuntimeException and gives a more explicit indication to the client that a rollback occurred. If the client did not propagate a transaction to the EJB, the system exception will be caught and rethrown as an EJBException.
This does not follow what the ejb-core specs say. I guess it is a problem with JBoss. I will install Glassfish anf try it again. I will post back the results. [ July 06, 2008: Message edited by: Sergio Tridente ]
The specs, of course. As I said, it works fine on Glassfish: it throws ServerException, which is a subclass of RemoteException, when the Bean's interface extends Remote. But it throws EJBException when it does not extend Remote, even if it is annotated with @Remote.