Link to home
Start Free TrialLog in
Avatar of baabul
baabul

asked on

I fail setting the transaction timeout in Weblogic 8.1sp5

In my case, I try to use one XA transaction to coordinate multiple databases operation, so I setup multiple XA-style DBPool according to the multiple databases. I set the "Enable XA Transaction Timeout=true" & "XA Transaction Timeout=300" in every XA-style DBPool via Weglogic admin console. But after I restart the server and test my code with it. This exception "Transaction timed out after 31 seconds" thrown by weblogic. Could you advise me how to set the transaction timeout correctly?
Avatar of ECollin
ECollin

hi,

are you using ejbs ?
Do you managed transaction inside your code, or do you left the container to deal with ?

Emmanuel
Avatar of baabul

ASKER

Hi,

No ejb's in my case. I use the Hibernate(3.1.3) as the data access tier. Actually I create multiple XA-style datasources in weblogic for my different databases, then config these datasources in Hibernate for creating multiple SessionFactories (one factory for one database). Then implement a JTA interceptor for handling the transaction. When a jta method is invoked, my interceptor will capture it and inject jta transaction code before and after its invoking. The pseudocode has been appended in the end for your reference. The UserTransaction got from weblogic will control the whole transaction processing, so I config its timeout in weblogic will affect on my code. But it's not, the exception "Transaction timed out after 31 seconds" is still thrown by weblogic. I don't know how I can handle it, please advise.

Thanks,
Amax

*****my code************
UserTransaction tx = null;
try {                        
      Context ctx = JndiHelper.instance().getContext();
      String jtstransaction = "javax.transaction.UserTransaction";
      
      if(JndiHelper.instance().getJndiParam("jta.UserTransaction")!=null){
            jtstransaction = JndiHelper.instance().getJndiParam("jta.UserTransaction");
      }
      
      tx = (UserTransaction)ctx.lookup(jtstransaction);
      tx.begin();
      Object retObject = method.invoke(target, args);
      tx.commit();
      return retObject;
}catch(Exception e){
    if(tx!=null){
          tx.rollback();
    }
    throw new Exception(e.getCause());
}
************************
Avatar of baabul

ASKER

All,

I have finished my case, just set the UserTransaction.setTimeout to the seconds I expect.

Thanks,
Amax
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial