5 Replies Latest reply on Jul 16, 2007 11:31 AM by davidbalazic

    How to detect transaction timeout ?

    davidbalazic Newbie

      Sometimes during a business method call (in a stateless bean) the transaction times out and the changes are not committed.
      The problem is, that the calling client does not receive any exception or other form of error indication.

      Can the bean method get access to the transaction before it returns, so it can check its state ?

      It is a Stateless bean with container managed transactions.
      SW is jboss 4.0.4GA on windows with hibernate accessing Oracle DB.

      I tried this :

      @Resource SessionContext ejbContext;
      
      public Object myMethod()
      {
       do_something ();
      
       int status = ejbContext.getUserTransaction( ).getStatus();
       return evaluate(status);
      }
      


      But that does not work of course. It gives :
      
      javax.ejb.EJBException: java.lang.IllegalStateException: Container ProductServiceMgmtFeatureWebAcBean: it is illegal to inject UserTransaction into a CMT bean
      


      Is there any way for the client to be notified that the method did not successfully end ?

      I read about the <exception-on-rollback> optin, but it does not seem to make any difference. ( I read about it here : http://jira.jboss.com/jira/browse/JBAS-1509 )

      Regards,
      David