4 Replies Latest reply on Apr 9, 2013 8:48 AM by AmolJ

    EJB 3 Transaction Issue

      Our application uses Struts2, EJB3.0, JBoss4.2GA, MS-SQL Server2k5. We have one method in SLSB. This method insert two records in the DB table. On production we faced an issue that only one among these two row got inserted. We are using CMT. No transaction attribute is specified on the method so it is expected to be REQUIRED. One more thing, this issue occured on production env only and Dev env works fine. I am not figuring what could be the reason that half of the method is committing and half one doesn't. Also attaching the method code below:
      public Boolean receiveProcceds(ApplicationEventTracker event,Object object,Date currentSystemDate){ 
      SupplementaryBankAccount supplementaryBankAccount = (SupplementaryBankAccount) object;
           *  Estate Bank Balance Debit Transaction
          TransactionDetails estateTransaction = new TransactionDetails();
          estateTransaction.setEstateId(new Estate(supplementaryBankAccount.getEstateId().getEstateId()));
          estateTransaction.setSuppBankAccountNo(new SupplementaryBankAccount(supplementaryBankAccount.getSupplementaryBankAccountId()));
          // TransactionType = 9 for AP - Special Account Proceeds
          estateTransaction.setTransactionTypeId(new TransactionType(9));
           * Transaction Amount is Negative as Bank Balance is debited
          estateTransaction=(TransactionDetails) auditor.create(event, estateTransaction);
          //Added for BankBalance issue
          updateEstateBankBalance.updateBankBalance(event,estateTransaction.getTransactionAmount(),estateTransaction.getEstateId().getEstateId(), auditor, estateTransaction.getTransactionId(), datasource));
           *  Supplementary Bank Account Credit Transaction
          TransactionDetails suppBankAccountTransaction = new TransactionDetails();
          suppBankAccountTransaction.setEstateId(new Estate(supplementaryBankAccount.getEstateId().getEstateId()));
          suppBankAccountTransaction.setSuppBankAccountNo(new SupplementaryBankAccount(supplementaryBankAccount.getSupplementaryBankAccountId()));
          // TransactionType = 9 for AP - Special Account Proceeds
          suppBankAccountTransaction.setTransactionTypeId(new TransactionType(9));
           * Transaction Amount is Positive as Bank Balance is credited
          suppBankAccountTransaction=(TransactionDetails) auditor.create(event, suppBankAccountTransaction);
          supplementaryBankAccount.setBankBalance(updateEstateBankBalance.updateSuppAccBankBalance(event,suppBankAccountTransaction.getTransactionAmount(),supplementaryBankAccount.getSupplementaryBankAccountId(), auditor));
          return true;
        • 1. Re: EJB 3 Transaction Issue
          If no record is inserted and you get no exception then I am going to assume the simplest answer of all: no persist is actually executed. But since you don't post the actual code that does ORM related actions, I can only guess.
          • 2. Re: EJB 3 Transaction Issue
            Hi gimbal2. Thanks for your reply.

            We are injecting one bean inside our beans for audit purpose activities through below line:
            AuditorDAORemote auditor;
            Thus in my previous posted code there is line:
            Please find below code for create method of AuditorDAOBean:
            public Object create(ApplicationEventTracker event,Object object) {
                 return object;
            Before create method works we have applied @AroundInvoke interceptors for storing respective audit purpose activities.

            I hope this help to clear the concern that my previous code does not contain actual ORM related actions.

            Now can we reach towards the issue that what could be the reason causing one transaction to persist and not the another one?
            • 3. Re: EJB 3 Transaction Issue
              Causing a rollback would be a way. There are no clear-cut answers here; you have code and it is doing something you're not expecting. Keep digging and until you have proof otherwise - keep assuming its a silly mistake you're making and not some kind of failure outside of your control.
              • 4. Re: EJB 3 Transaction Issue
                Hi Gimbal2, Thanks for your replies.