title: Jboss TimerService Timers Lost and not Fired
body: <p>I'm trying to use timers with JBOSS 4.3 over RedHat Linux with Java Sun 1.6, the timers are created but never fired</p>
  
  <p>Mi Class is </p>
  
  <pre><code>@Stateless
  @TransactionManagement(TransactionManagementType.CONTAINER)
  public class MyTimerBean implements MyTimer,TimedObject {
  private static final Logger logger = Logger.getLogger(MyTimer.class);
  
  @Resource
  private TimerService ts;
  
  @Resource
  private SessionContext ctx;
  private TimerService ts2;
  
  Timer y;
  
  private String miString=null;
  public void startTimer() throws NamingException { 
      logger.debug("DRFXML starting.."); 
      miString="Timers exists";
      Timer x = ts.createTimer( 6000L, null);
      logger.debug("DRFXML 1.Next Timeout "+x.getNextTimeout());
      x = ts.createTimer( 36000L, null);
      logger.debug("DRFXML 2.Next Timeout "+x.getNextTimeout());
      x = ts.createTimer( 1036000L, null);
      logger.debug("DRFXML 3.Next Timeout "+x.getNextTimeout());
      x= ts.createTimer(15000, null);
      logger.debug("DRFXML 4.Next Timeout "+x.getNextTimeout());
  
      ts2 = ctx.getTimerService();
      y = ts2.createTimer(30000, "Another");  
      logger.debug("DRFXML 5.Next Timeout "+y.getNextTimeout());
      this.showTimers();
  
  }
  
  public void showTimers(){
      if (ts.getTimers()==null){
          logger.error("DRFXML Error Timer is null");
      }
      else if (ts.getTimers().size()==0){
          logger.error("DRFXML Error 0 Timers ");
      }else
      {
          logger.debug("DRFXML Timers = "+ts.getTimers().size());
      }
  
      if (ts2.getTimers()==null){
          logger.error("DRFXML Error Timer2 is null");
      }
      else if (ts2.getTimers().size()==0){
          logger.error("DRFXML Error 0 Timers in TS2 ");
      }else
      {
          logger.debug("DRFXML Timers2 = "+ts2.getTimers().size());
      }
  
              logger.debug("DRFXML My String="+miString);
  
      if(y==null){
          logger.debug("DRFXML Error timer is null");
      }
      else{
                      //This line raise the exception
          logger.debug("DRFXML timer y NextTimeout"+y.getNextTimeout());
      }
  
  
  
  
  }
  
  @PreDestroy
  public void tidyUp() {
      logger.debug("DRFXML Killing Timers....");
      for (Object obj : ts.getTimers()) {
          Timer timer = (Timer)obj;
          timer.cancel();
          logger.debug("DRFXML Timer Canceled");
      }   
  }
  
  
  @Timeout
  public void ejbTimeout(Timer arg0) {
      logger.debug("DRFXML TimeOut!!");
      System.out.println("DRFXML EJBTimeOut!!");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The interface is</p>
  
  <pre><code>@Local
  public interface MyTimer {
  void startTimer() throws NamingException;
  @PreDestroy
  void tidyUp();
  public void showTimers();
  }
  </code></pre>
  
  <p>This is the Log</p>
  
  <pre><code>2012-02-18 21:17:44 CLST  DEBUG  DRFXML starting..
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML 1.Next Timeout Sat Feb 18 21:17:50 CLST 2012
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML 2.Next Timeout Sat Feb 18 21:18:20 CLST 2012
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML 3.Next Timeout Sat Feb 18 21:35:00 CLST 2012
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML 4.Next Timeout Sat Feb 18 21:17:59 CLST 2012
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML 5.Next Timeout Sat Feb 18 21:18:14 CLST 2012
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML Timers = 5
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML Timers2 = 5
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML My String=Timers exists
  2012-02-18 21:17:44 CLST  DEBUG  DRFXML timer y NextTimeoutSat Feb 18 21:18:14 CLST 2012
  </code></pre>
  
  <p>When the showTimers method is called again, in the same EJB,  the timers dont exists!!!  :,( </p>
  
  <pre><code>2012-02-18 21:17:46 CLST  DEBUG  DRFXML Error 0 Timers 
  2012-02-18 21:17:46 CLST  ERROR  DRFXML Error 0 Timers in TS2 
  2012-02-18 21:17:46 CLST  DEBUG  DRFXML My String=Timers exists
  
  Caused by: javax.ejb.NoSuchObjectLocalException: Timer was canceled
      at org.jboss.ejb.txtimer.TimerImpl.assertTimedOut(TimerImpl.java:402)
      at org.jboss.ejb.txtimer.TimerImpl.getNextTimeout(TimerImpl.java:257)
      at cl.walmart.presto.ti.servicios.solicitud.beans.RescataXmlFirmadoBean.showTimers(RescataXmlFirmadoBean.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  </code></pre>
  
  <p>You can see "My String" exists, is the same EJB!!</p>
  
  <p>Why my "Timer was canceled" ?</p>
  
  <p>Note:
  In a Jboss Local in my PC the code works, but in linux with redhat not work!!    >:oC</p>
  
  <p>Thanks in Advance</p>