users@javaee-spec.java.net

[javaee-spec users] [jsr342-experts] Fwd: [jta-spec users] new TransactionalException

From: Linda DeMichiel <linda.demichiel_at_oracle.com>
Date: Mon, 04 Feb 2013 18:35:51 -0800

Forwarding at the request of the JTA spec lead.

Exceptions thrown by the transaction interceptor need to be runtime
exceptions to conform to the requirement of the interceptors spec
that interceptors can only throw checked exceptions that are
thrown by the method on which they interpose. This new exception
also provides more consistency with the default settings for rollback
and with EJB CMT behavior.

Please review and follow up by posting either here or at
users_at_jta-spec.java.net (or both). The current draft of the JTA 1.2
spec can be downloaded at java.net/projects/jta-spec/sources/spec-source-repository/content/jta-1_2-spec_v2.pdf?rev=4

thanks,

-Linda


-------- Original Message --------
Subject: [jta-spec users] new TransactionalException
Date: Mon, 4 Feb 2013 15:14:36 -0500
From: Paul Parkinson <paul.parkinson_at_oracle.com>
Reply-To: users_at_jta-spec.java.net
To: users_at_jta-spec.java.net



Hello,

I wanted to explicitly call out a new TransactionalException that is in the latest rev of the spec, the javadoc for
which is below.

It serves as a RuntimeException extension wrapping exceptions thrown by the transactional interceptors and allows for
closer alignment with the exception handling behavior that occurs in EJB (eg the runtime exceptions
EJBTransactionRequiredException and EJBException that result in transactions being marked for rollback) as a default.

Please replies with any comments or questions if you would.

Thanks,
Paul

Class TransactionalException

public class javax.transaction.cdi.TransactionalException extends java.lang.RuntimeException
{

public TransactionalException(String s, Throwable throwable); }

RuntimeException used to rethrow Exceptions thrown from Transactional annotation interceptors implementation.

This results in the transaction being marked for rollback by default.

The original Exception is set as the nested exception and includes TransactionRequiredException for the case where a
bean with TxType.MANDATORY is called outside a transaction context, InvalidTransactionException for the case where a
bean with TxType.NEVER is called inside a transaction context, and various commit-time exceptions such as
RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, and
SystemException.

Constructors

TransactionalException
public TransactionalException(String s, Throwable throwable)

Create an TransactionalException with a given string and nested Throwable.