----- Original Message ----
From: Dragan Ljubojevic <ljufa_at_yahoo.com>
To: dev_at_glassfish.dev.java.net
Sent: Monday, December 17, 2007 11:48:17 AM
Subject: Cause of RollbackException in transaction
I'm developing stateless session bean exposed as web service with bean
managed transactions management
(@TransactionManagement(TransactionManagementType.BEAN)).
All web methods looks similar to this:
@Resource
protected UserTransaction tx;
@PersistenceContext
protected EntityManager em;
public void myWebMethod(.....) throws MyException{
try{
tx.begin();
... call some write db operations on different entities using
EntityManager
tx.commit();
} catch(RollbackException ex){
// here I need to know cause of rollbackexception using
ex.getCause() in order to return message with reason why operation
can't be
completed to method caller.
// But ex.getCause() returns null ?
try{
tx.rollback();
}catch (Exception e){
}
throw new MyException("Reason of error....");
}
I''v checked out appserv-core module and found that
J2EETransaction.commit() ignores catched RuntimeExceptinon at line 420
(and other places).
Actually I'm not sure it's an real issue, but it would quite useful to
have a cause exception(i.e. SQLException) of RollbackException in
service method from which we can pull information of real cause of
problem
and send appropriate message to service method caller.
Regards
Dragan.
Dragan Ljubojevic wrote:
> Why J2EETransaction.commit() implementation ignores cause of
> RollbackException? And why javax.transaction.RollbackException does
not define/implement
> constructor RollbackException(String message, Throwable throwable);
>
>
>
> Current implementation of commit method catches
> RuntimeException, calls setRollbackOnly() and throws
RollbackException with
> string key only(without cause).
>
>
>
>
> Will you break J2EE specification or lose some of
> distribution transaction features if you expand RollbackException
class with
> new constructor and throw such constructed exception in commit()
method?
>
> If
> not, can we expect such implementation in some of the future
releases?
>
>
>
>
> Cause exception (i.e. SQLException ) can be useful in
> providing appropriate validation messages to web service clients. In
this way
> we can put some input data validation on database back.
>
Please fine an issue.
regards
sankar
>
>
> Regards
> Dragan
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs