6 Replies Latest reply on Aug 30, 2011 8:44 AM by Rich Midwinter

    @Schedule timer service in jboss-as-web-7.0.1 not working

    u j Novice

      As far as I understand, the annotation @Schedule should work in the new release 7.0.1.

      However, nothing happens. My code is:

       

      @Singleton

      @Startup

      public class MessageService {

       

          @Schedule(hour="*", minute="*")

          public void execute() {

           // print to log    

           }

       

      This should go off every minute, but the method is never called.

      Is there anything else to do? I use the standalone server.

       

      Thanks

        • 1. Re: @Schedule timer service in jboss-as-web-7.0.1 not working
          jaikiran pai Master

          Are you using standalone-preview.xml of "everything" distribution? The standalone.xml doesn't have timer service support.

          1 of 1 people found this helpful
          • 2. Re: @Schedule timer service in jboss-as-web-7.0.1 not working
            u j Novice

            Ok that was the mistake.

             

            But now I get an error:

             

            11:19:00,002 ERROR [stderr] (EJB Timer Thread) Exception in thread "EJB Timer Thread" java.util.concurrent.RejectedExecutionException

             

            11:19:00,003 ERROR [stderr] (EJB Timer Thread)     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1768)

             

            11:19:00,003 ERROR [stderr] (EJB Timer Thread)     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)

             

            11:19:00,003 ERROR [stderr] (EJB Timer Thread)     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)

             

            11:19:00,004 ERROR [stderr] (EJB Timer Thread)     at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:78)

             

            11:19:00,004 ERROR [stderr] (EJB Timer Thread)     at org.jboss.ejb3.timerservice.mk2.TimerServiceImpl$Task.run(TimerServiceImpl.java:1039)

             

            11:19:00,004 ERROR [stderr] (EJB Timer Thread)     at java.util.TimerThread.mainLoop(Timer.java:512)

             

            11:19:00,005 ERROR [stderr] (EJB Timer Thread)     at java.util.TimerThread.run(Timer.java:462)

             

             

            11:19:00,048 ERROR [org.jboss.ejb3.timerservice.mk2.task.TimerTask] (pool-4-thread-1) Error invoking timeout for timer: [id=575cc7d1-5651-4d97-9f82-4574e1f96eea timedObjectId=MessageService auto-timer?:true persistent?:true timerService=org.jboss.ejb3.timerservice.mk2.TimerServiceImpl@7361eccb initialExpiration=Wed Aug 24 00:00:00 CEST 2011 intervalDuration(in milli sec)=0 nextExpiration=Wed Aug 24 11:08:00 CEST 2011 timerState=IN_TIMEOUT: java.lang.RuntimeException: Unknown timeout method public void com.myapp.MessageService.execute()

                at org.jboss.as.ejb3.component.singleton.SingletonComponentInstance.invokeTimeoutMethod(SingletonComponentInstance.java:67)

                at org.jboss.as.ejb3.timerservice.SingletonTimedObjectInvokerImpl.callTimeout(SingletonTimedObjectInvokerImpl.java:48)

                at org.jboss.ejb3.timerservice.mk2.task.CalendarTimerTask.callTimeout(CalendarTimerTask.java:73)

                at org.jboss.ejb3.timerservice.mk2.task.TimerTask.run(TimerTask.java:120)

                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_24]

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_24]

                at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_24]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]

                at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]

             

            If you look at ThreadPoolExecutor.execute, the line is reject(command):

             

            public void execute(Runnable command) {
                if (command == null)
                    throw new NullPointerException();
                if (poolSize >= corePoolSize || !addIfUnderCorePoolSize(command)) {
                    if (runState == RUNNING && workQueue.offer(command)) {
                        if (runState != RUNNING || poolSize == 0)
                            ensureQueuedTaskHandled(command);
                    }
                    else if (!addIfUnderMaximumPoolSize(command))
                        reject(command); // is shutdown or saturated
                }
            }

             

            I have found out that this does not happen if I set persistence=false in @Schedule!

             

            Thanks,

            Ulrich

            • 3. Re: @Schedule timer service in jboss-as-web-7.0.1 not working
              Rich Midwinter Newbie

              I'm getting a similar error (below). I've tried setting persistent=false in the @Schedule annotation but it doesn't seem to make any difference - the logs indicate it's not even respected. Everything seems to work though, my timer is called successfully?!

               

              16:34:00,027 INFO  [org.jboss.ejb3.timerservice.mk2.task.TimerTask] (pool-5-thread-1) Timer: [id=1fa3a3d9-8012-47b6-8f75-452a02b36a8b timedObjectId=SchedulerBean auto-timer?:true persistent?:true timerService=org.jboss.ejb3.timerservice.mk2.TimerServiceImpl@120e178 initialExpiration=Mon Aug 29 00:00:00 GMT 2011 intervalDuration(in milli sec)=0 nextExpiration=Mon Aug 29 16:36:00 GMT 2011 timerState=IN_TIMEOUT will be retried

              16:34:00,027 INFO  [org.jboss.ejb3.timerservice.mk2.task.TimerTask] (pool-5-thread-1) Retrying timeout for timer: [id=1fa3a3d9-8012-47b6-8f75-452a02b36a8b timedObjectId=SchedulerBean auto-timer?:true persistent?:true timerService=org.jboss.ejb3.timerservice.mk2.TimerServiceImpl@120e178 initialExpiration=Mon Aug 29 00:00:00 GMT 2011 intervalDuration(in milli sec)=0 nextExpiration=Mon Aug 29 16:36:00 GMT 2011 timerState=IN_TIMEOUT

              16:34:00,034 ERROR [org.jboss.ejb3.timerservice.mk2.task.TimerTask] (pool-5-thread-1) Error during retyring timeout for timer: [id=1fa3a3d9-8012-47b6-8f75-452a02b36a8b timedObjectId=SchedulerBean auto-timer?:true persistent?:true timerService=org.jboss.ejb3.timerservice.mk2.TimerServiceImpl@120e178 initialExpiration=Mon Aug 29 00:00:00 GMT 2011 intervalDuration(in milli sec)=0 nextExpiration=Mon Aug 29 16:36:00 GMT 2011 timerState=RETRY_TIMEOUT: java.lang.RuntimeException: Unknown timeout method public void com.htu.fizio.impl.SchedulerBean.checkAttendance()

                        at org.jboss.as.ejb3.component.singleton.SingletonComponentInstance.invokeTimeoutMethod(SingletonComponentInstance.java:67)

                        at org.jboss.as.ejb3.timerservice.SingletonTimedObjectInvokerImpl.callTimeout(SingletonTimedObjectInvokerImpl.java:48)

                        at org.jboss.ejb3.timerservice.mk2.task.CalendarTimerTask.callTimeout(CalendarTimerTask.java:73)

                        at org.jboss.ejb3.timerservice.mk2.task.TimerTask.run(TimerTask.java:120)

                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [:1.7.0]

                        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [:1.7.0]

                        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [:1.7.0]

                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]

                        at java.lang.Thread.run(Thread.java:722) [:1.7.0]

              • 4. Re: @Schedule timer service in jboss-as-web-7.0.1 not working
                jaikiran pai Master

                I forgot about this thread. Let me try reproducing this in a testcase.

                • 6. Re: @Schedule timer service in jboss-as-web-7.0.1 not working
                  Rich Midwinter Newbie

                  Thanks Jaikiran (interesting fix, first time I can recall seeing IdentityHashMap used).

                   

                  For anyone else finding this, I think the errors I was still getting after setting the schedule to not be persistent were presumably from previous attempts which were persisted. Removing the contents of ${JBOSS_HOME}/standalone/data/time-service-data seems to have stopped them reappearing.