Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:41:33+00:00 2026-05-29T07:41:33+00:00

I am having a problem with EJB components that are responsible for starting a

  • 0

I am having a problem with EJB components that are responsible for starting a transaction.
I am using Jboss 5.01.

Basically I would like to execute a given code after a specific transaction was committed. the specific code also involves calling an EJB component which makes it’s own transactions.

To make sure that my code is executed after a previous transaction is committed I’ve registered a
Synchronization component into a transaction component :

Transaction tx = transactionManager.getTransaction();
tx.registerSynchronization(new CallbackSynchronization());

The Synchronizaton implementation basically does the following:

class CallbackSynchronization implements Synchnronization {

    private AccountService service;  // This is a Stateless session bean

    public CallbackSynchronization(AccountService service) {
        this.service   = service;
    }

    public afterCompletion(int status) {
        if(Status.STATUS_COMMITTED == status) {
            service.deleteAccounts();
        }
    }
}

Problem is that when I call the service.deleteAccounts() I get an exception that eventually tells me that the transaction is not active.

And this is what confuses me. an EJB with methods marked with @TransactionAttribute(TransactionAttributeType.REQUIRED) will create a new transaction if one is not active(the REQUIRED is the default in JBOSS).

Why then am I getting “Transaction not active” ?

Many Thanks,

Yaniv

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:41:33+00:00Added an answer on May 29, 2026 at 7:41 am

    The problem is that the original transaction that you started is still associated with the thread (even though it is in a COMMITTED status). One of the significant differences between using the Transaction and the TransactionManager is that the later’s commit() and rollback() methods will unassociate the transaction from the thread. To quote from the javadoc for both methods:

    When this method completes, the thread is no longer associated with a
    transaction.

    There’s two ways to deal with this (and I am outlining them in a very raw manner which you may want to refine a bit).

    Option 1: Issue a rollback or commit against the transaction manager (in a try block because it will fail).

    public afterCompletion(int status) {
      if(Status.STATUS_COMMITTED == status) {
        try { transactionManager.rollback(); } catch (Throwable t) {}
        service.deleteAccounts();
      }
    }
    

    Option 2: Start a new transaction, which will satisfy the REQUIRED attribute of your EJB by pre-starting a transaction, but you need to stick around and manage it which gets sticky.

    public afterCompletion(int status) {
      if(Status.STATUS_COMMITTED == status) {
        try { 
          transactionManager.begin();
          service.deleteAccounts();
          transactionManager.commit();
        } catch (Exception e) {
            // ... handle exception here
        }
      }
    }
    

    Option 3: The cleanest option may be to mark the EJB method as REQUIRES_NEW as this will force the EJB container to start a new transaction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are having problem with the server migration. We have one application that are
I am having problem in getting reference of Ajax control extender using $find() or
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
I'm having problem restricting a query in mdx, using except function at where clause.
hey there i am having problem i have List<List<memoryCard>> that i want to show
hi I'm having problem with my database. I'm using access as my database and
Im having problem with single value inserts. Using pyodbc LL= [] .... sqla =
Im having problem's adding map markers to gmaps using jquery. Here is my code
I´m having problem using validation on DropDownListFor ... My Model : public class User
having problem with null pointer exception and i read few article bout that error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.