Hi Djencks/Dblevins,
As we had discussed earlier about this issue and the possible patch. It
seems we cannot use javax.transaction.
TransactionRolledbackException.initCause(e) instead there is another class
with in openEJB
org.apache.openejb.core.transaction.TransactionRolledbackException which can
be utilized. So can we go ahead
and use this exception class. Are there any reasons why we had not used this
class earlier?
For your reference
have a look at line no 146 in the class
https://svn.apache.org/repos/asf/openejb/tags/openejb-3.0.3/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionPolicy.java
Once I use this class I see better logging however it stills seems
incomplete. What can we do to get more logging in this case?
Snippets of log from my eclipse when I run the client
Caused by: java.lang.Exception: Transaction has timed out
at
org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:261)
... 18 more
Snippets of log from my geronimo.log
2011-02-24 14:35:50,625 DEBUG [OpenEJB] finished invoking method create.
Return
value:proxy=com.test.ibm.TestTransactionInterface;deployment=test4/TestTransaction;pk=205efedb35aa1fff:ef95222:12e56ea419b:-7fe4
2011-02-24 14:35:50,640 DEBUG [jndi] JNDI REQUEST:
JNDI_LOOKUP:null:TestTransactionRemote -- RESPONSE:
JNDI_BUSINESS_OBJECT:STATEFUL:test4/TestTransaction:com.test.ibm.TestTransactionInterface:205efedb35aa1fff:ef95222:12e56ea419b:-7fe4
2011-02-24 14:35:50,718 INFO [Transaction] TX RequiresNew: Suspended
transaction null
2011-02-24 14:35:50,718 INFO [Transaction] TX RequiresNew: Started
transaction org.apache.geronimo.transaction.manager.TransactionImpl@f5472d
2011-02-24 14:35:50,750 INFO [Runtime] Starting OpenJPA 1.2.2
2011-02-24 14:35:50,843 INFO [JDBC] Using dictionary class
org.apache.openjpa.jdbc.sql.DerbyDictionary (Apache Derby 10.5.3.0 -
(802917) ,Apache Derby Embedded JDBC Driver 10.5.3.0 - (802917)).
2011-02-24 14:36:02,015 INFO [Transaction] TX RequiresNew: Committing
transaction org.apache.geronimo.transaction.manager.TransactionImpl@f5472d
2011-02-24 14:36:02,109 INFO [Transaction] The transaction has been rolled
back rather than commited: Unable to commit: transaction marked for rollback
2011-02-24 14:36:02,109 INFO [Transaction] TX RequiresNew: No transaction
to resume
2011-02-24 14:36:02,109 DEBUG [ejb] EJB REQUEST:
EJB_OBJECT.BUSINESS_METHOD:test4/TestTransaction:firstMethod:205efedb35aa1fff:ef95222:12e56ea419b:-7fe4
-- RESPONSE:
EJB_APP_EXCEPTION:org.apache.openejb.core.transaction.TransactionRolledbackException:
Transaction was rolled back, presumably because setRollbackOnly was called
during a synchronization: Unable to commit: transaction marked for rollback
Thanks
Ashish
On Thu, Feb 24, 2011 at 9:26 AM, David Jencks david_jen...@yahoo.comwrote:
On Feb 23, 2011, at 7:35 PM, Kevan Miller wrote:
On Feb 22, 2011, at 4:37 PM, David Jencks wrote:
cf
https://issues.apache.org/jira/browse/GERONIMO-4576
https://issues.apache.org/jira/browse/OPENEJB-1091
For a long time we've known of this problem where an exception thrown by
a transaction synchronization that causes a transaction to be marked for
rollback only is lost. When the user or openejb tries to commit the
transaction the transaction manager throws a RollbackException which
currently doesn't have any information about the original exception.
People have complained about this for a long time now we're trying
to fix it.
There are two parts AFAICT. I think in openejb we just need to take the
TransactionRolledBackException we are currently throwing and call initCause
with the RollbackException from the tm. In TransactionPolicy this would be
something like
} catch (RollbackException e) {
txLogger.info(The transaction has been rolled back rather
than commited: + e.getMessage());
// TODO can't set initCause on a
TransactionRolledbackException, update the convertException and related code
to handle something else
Throwable txe = new
javax.transaction.TransactionRolledbackException(Transaction was rolled
back, presumably because setRollbackOnly was called during a
synchronization: +e.getMessage());
--throw new ApplicationException(txe);
++throw new ApplicationException(txe.initCause(e);
In the transaction implementation we need to keep track of the exception
that caused us to mark rollback only and then use it as the cause of the
RollbackException, e.g.
private Exception markRollbackCause;
...
RollbackException rollbackException = new RollbackException(Unable to
commit: transaction marked for rollback);
if (markRollbackCause != null) {
rollbackException.initCause(markRollbackCause);
}
throw rollbackException;
...
private void markRollbackCause(Exception e) {
if (markRollbackCause == null) {
markRollbackCause = e;
}
}