Hello,
 
I am trying to run an example about transactions using timeout ... and i was surprised when i ran the code ...
 
Using another transaction manager, like jotm, bitronix, the time-out from a user transaction do the following
 
timeout := X seconds
ut start
      action 1
      action 2
      action 3
ut commit
if error  ... ut rollback
 
if action1 or action 2 o action 3 are into the period of X seconds , they will not executed ... for example ... if  action 1 got a lot of time, more than timeout, then,
action 2 and action 3 never been executed ... right ...
 
 
But, using jboss-user transaction, ... the time-out exception is throwed when action 3 finished !!!! ... the following sample shows my problem ..
 
package paq;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.annotation.Resource;
import javax.ejb.ApplicationException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.UserTransaction;

public class Tiempo extends javax.servlet.http.HttpServlet implements
  javax.servlet.Servlet {

 private static final long serialVersionUID = 8150995692542819134L;

 @Resource
 private UserTransaction ut;
 
 protected void doGet(HttpServletRequest request,
   HttpServletResponse response) throws ServletException, IOException {

  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  
  try {
   out.write("<br>" + new Date());
   ut.setTransactionTimeout(1);
   ut.begin();
   Thread.sleep(3000);
   out.write("<br>" + new Date());
   out.write("->1" + ut + "<br>");
   Thread.sleep(3000);
   out.write("<br>" + new Date());
   out.write("->2" + ut + "<br>");
   Thread.sleep(3000);
   out.write("<br>" + new Date());
   
   ut.commit();
  }
  
  catch (Exception e) {
   out.write("<br>" + new Date());
   out.write("<br>Excepcion:=" + e);
  }
 }
}

The exception from time-out is throwed after 9 seconds !!!!  nooo ... i need it al least at 2 seconds !!   and never run the hole of transaction ...
 
why do i need to run a completed tx when the first is broken into a timeout !!!  
 
if my transaction has  3 operations and a timeout is 4 hours ,   1.-  spends 1 hour,  2.- spends 1 hours , 3.- spends 2 hours ...    if i got a problem and the first one and second need 4 hours to finish, i don't want to wait  another 2 hours to recieve the time-out exception !!!
 
how can i resolve it
 
thank you