EJB-3.1 @Startup & @Schedule anotation in Apache Tomee to execute a timer

I have the following code to run Apache-tomee, I use eclipse to encode, and I want to run my simple schedule task using the @Schedule annotation when the application starts.

@Startup @Singleton public class ScheduleEJB { private static int count = 0; @Schedule(second="*/10", minute="*", hour="*", info="MyTimer") public void execute() { System.out.println("its running count..."+count); count++; } } 

When I deployed this code to Tomee, he received the following message and couldn’t start my execute () schedule method automatically at startup, where, since this code works fine in a glass shawl, but I won’t use it either a glass jboss fish.

December 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instance
INFO: Using the default implementation for ThreadExecutor
December 21, 2012 9:59:45 AM org.quartz.core.SchedulerSignalerImpl
INFO: Initialized Signaller Scheduler type: class org.quartz.core.SchedulerSignalerImpl
December 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler
INFO: Created by Quartz Scheduler v.2.1.6.
December 21, 2012 9:59:45 AM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
December 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler initialize
INFO: scheduler metadata: Quartz Scheduler (v2.1.6) "OpenEJB-TimerService-Scheduler" with an instance of "OpenEJB",
Scheduler class: 'org.quartz.core.QuartzScheduler' - runs locally.
NOT THE BEGINNING.
Currently on standby.
Number of completed tasks: 0
Using the thread pool 'org.apache.openejb.core.timer.DefaultTimerThreadPoolAdapter' - with 0 threads.
Using the job store "org.quartz.simpl.RAMJobStore" - which does not support persistence. and not clustered.

December 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instance
INFO: Quartz scheduler 'OpenEJB-TimerService-Scheduler' is initialized from an instance of properties provided externally.
December 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instance
INFO: Quartz Scheduler Version: 2.1.6
December 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler start
INFO: The OpenEJB Scheduler-TimerService-Scheduler _ $ _ OpenEJB is running.
December 21, 2012 9:59:45 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created by Ejb (deploy-id = ScheduleEJB, ejb-name = ScheduleEJB, container = My Singleton Container)
December 21, 2012 9:59:45 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Initial Ejb (Deployment ID = ScheduleEJB, ejb-name = ScheduleEJB, container = My Singleton Container)

+6
source share
2 answers

Have you already read the TomEE sample page? There is a similar example that actually works.

http://openejb.apache.org/examples-trunk/schedule-methods/README.html

Perhaps you could try and verify what is actually different from yours.

+1
source

In the latest version of TomEE, your code works fine. What was your version?

0
source

All Articles