8 Replies Latest reply on Jun 7, 2013 3:31 AM by Wolf-Dieter Fink

    TimerService weird behavior

    pawtur Newbie

      Hi Guys,

       

      I'm struggling with an issue with EJB 3.1 Timers on JBOSS 7.1.1. It seems to me to be a bug in the timer implementation, but I would appreciate if you confirm it or give me your thoughts on it.

       

      What I'm trying to achieve with the code below is to schedule execution of a timer every 3rd of a month between 00:00 till 12:00 every 5 minutes starting from 03.06.2013.

       

      [..]
      
      public void initTimer() {
      
                          Calendar start = Calendar.getInstance();
                          start.set(2013, Calendar.JUNE, 3, 2, 0);
      
                          ScheduleExpression expression = new ScheduleExpression();               
                          expression.month("*").dayOfMonth("3").hour("0-12").minute("0/5").second("0").start(start.getTime());
      
                          timer = timerService.createCalendarTimer(expression, new TimerConfig(null, false));
      
                          System.out.println("Current time: " + new Date());
                          System.out.println("Next execution time: " + timer.getNextTimeout());
                }
      
      [..]
      
      
      

       

      on JBoss 7.1.1 I get the following, accordingly to me incorrect, output:

       

       

      Current time: Thu Jun 06 10:10:57 CEST 2013

      Next execution time: Wed Jul 03 10:15:00 CEST 2013

       

       

      whereas with exactly the same code on Glassfish I get the following, accordingly to me correct, output:

       

       

      Current time: Thu Jun 06 10:09:26 CEST 2013

      Next execution time: Wed Jul 03 00:00:00 CEST 2013

       

       

      In both cases the date of the first execution (03.07.2013) is correct, but the time of the first execution is incorrect when the code is executed on JBOSS. The schedule should start at midnight, but instead it starts at 10:15:00. It seems to me that JBOSS is taking for some weird reason the current locale time into account here.