users@glassfish.java.net

Re: How to get SQLState for exceptions thrown while running CMP in Glassfish

From: <glassfish_at_javadesktop.org>
Date: Fri, 10 Apr 2009 04:35:57 PDT

I downloaded the [b]glassfish server source code[/b] and tried to debug while running my application and [b]found that it is getting the SQLException[/b] but [b]then it is throwing
javax.transaction.RollbackException[/b] with a message : "Transaction marked for rollback" [b]without passing any information whatsoever about the SQLException it caught earlier[/b].Then it is wrapping this with EJBException and then throws that exception.Probably that is the reason SQLstate and SQLCode are not available at the calling EJB.Below is the snippet of code which I mentioned above.This is inside [b]commit[/b] method of [b]J2EETransaction[/b] class [b]from line no 434 to line 447.[/b]

// check rollbackonly again, in case any of the beforeCompletion
                // calls marked it for rollback.
                if ( isRollbackOnly()) {
            //Check if it is a Local Transaction
            if(jtsTx == null) {
                        if ( nonXAResource != null )
                            nonXAResource.getXAResource().rollback(xid);
                        localTxStatus = Status.STATUS_ROLLEDBACK;
                        throw new RollbackException(sm.getString("enterprise_distributedtx.mark_rollback"));
            // else it is a global transaction
            } else {
                jtsTx.rollback();
                localTxStatus = Status.STATUS_ROLLEDBACK;
                throw new RollbackException(sm.getString("enterprise_distributedtx.mark_rollback"));
            }
                }
[Message sent by forum member 'satyaranjan2006' (satyaranjan2006)]

http://forums.java.net/jive/thread.jspa?messageID=341609