Thanks in advance
If a bean method throws a system exception and the caller is in the same transaction, the caller will receive a TransactionRolledBackException/TransactionRolledBackLocalException, right? (HFEJB, page 552 too) What happens if the caller is not in the same transaction, for example, if the method has a 'RequiresNew' attribute? Which exception could the caller receive?
I think it will not roll back the previous transaction(which is propagated from clent or prvious bean),but will throw RemoteException for remote clients and EJBException for local clients
Bean method runs in the context of a transaction that the Container started immediately before dispatching the business method. This case may happen with Required and RequiresNew attributes.
all other exceptions
Log the exception or error.
Rollback the container-started transaction.
Throw RemoteException to remote client; throw EJBException to local client.
Receives RemoteException or EJBException.
If the client executes in a transaction, the client�s transaction may or may not be marked for rollback.
If the client has unspecified transaction context, it has similar results. TransactionRolledbackException is only thrown when bean transaction is the same of the caller.
However, if the callers lets the exception to propagate... TransactionRolledbackException/TransactionRolledbackLocalException are system exception, I think that caller transaction would be rolled back too. Because of that (I believe), the specification says:
"If the client executes in a transaction, the client�s transaction may or may not be marked for rollback."
[ August 10, 2005: Message edited by: Lautaro Brasseur ]
B. In HFEJB, page 582, says that the <method-intf> tag can be used to differentiate methods with same name in component and home interfaces, regarding security access. Can this tag be applied for transaction attributes too? Or if the same method are used in both, component and home interfaces, the transaction attribute must be the same?
Yes, this tag can be applied for transaction attributes too, as per the DD DTD.
C. Page 552 of HFEJB says that TransactionRequiredException and TransactionRequiredLocalException are thrown when you call a method with 'Mandatory' attribute without having the caller a transaction active. Which exception is thrown if you call a method with attribute 'Never' from a client with an active transaction? Is there an equivalent exception?
Yes, they are java.rmi.RemoteException and java.ejb.EJBException for remote and local clients respectively. Spec Page 359.
[ August 11, 2005: Message edited by: seemapanth Joshi ]