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.


#184 No rollback for SessionSynchronization

v2.4 (stable)
Scott M Stark
Michael Rettig

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

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

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

if (notifySession)
try {
(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.


  • Scott M Stark
    Scott M Stark

    Logged In: YES

    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

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

    Logged In: YES

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