Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#184 No rollback for SessionSynchronization

v2.4 (stable)
open-fixed
Scott M Stark
5
2002-04-05
2002-03-30
Michael Rettig
No

The session synchronization interface allows sessions
to be notified of the begin and end of a transaction.

Here are the specifications from the J2EE docs..

****J2EE Specifications******
The beforeCompletion method notifies a session Bean
instance that a transaction is about to be committed.
The instance can use this method, for example, to
write any cached data to a database.
This method executes in the proper transaction
context.

Note: The instance may still cause the container to
rollback the transaction by invoking the
setRollbackOnly() method on the instance context, or
by throwing an exception.

*********END J2EE Specs*************

Unfortunately, JBoss does not notify the transaction
of the exception, so the error is simply logged and
ignored.

Here is the offending code.
........
package org.jboss.ejb.plugins;
.......
public class StatefulSessionInstanceInterceptor
.............
private class InstanceSynchronization implements
Synchronization
............
public void beforeCompletion()
{
// lock the context the transaction is being
commited (no need for sync)
ctx.lock();

if (notifySession)
{
try {
beforeCompletion.invoke
(ctx.getInstance(), new Object[0]);
} catch (Exception e) {
***************THIS IS THE PROBLEM******************
log.error("failed to invoke
beforeCompletion", e); }
}
}

This should be changed to a RuntimeException with the
actual exception nested inside and thrown to the
calling transaction so it can roll back.

Furthermore, the exception needs to be handled and
thrown to the client so the client can process it.

I've written a testcase to reproduce the problem. If
needed I can give this to you.

I've comfirmed the problem is still present in the
latest nightly source distribution (as of 3/30/02),
and also in the 2.4 stable release.

Discussion

  • Scott M Stark
    Scott M Stark
    2002-04-05

    Logged In: YES
    user_id=175228

    An initial fix is committed for 2.4.5 but the exception
    propagated back to the client needs work.

     
  • Scott M Stark
    Scott M Stark
    2002-04-05

    • labels: 324886 --> JBossServer
    • assigned_to: nobody --> starksm
    • status: open --> open-fixed
     
  • Heather Lloyd
    Heather Lloyd
    2002-11-21

    Logged In: YES
    user_id=653235

    has this bug been fixed? i'm using jboss 3.0.3 and am having
    exactly this problem. please advise. thx