I have following code to run on Apache-tomee, i am using eclipse for coding, and i want to run my simple schedule job using @Schedule annotation at application start-up.
@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 on Tomee, it get me following message and unable to run my schedule method execute() automatically at startup, where as this code works fine in glassfish, but i am not going to use it either glassfish of jboss.
Dec 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Using default implementation for ThreadExecutor
Dec 21, 2012 9:59:45 AM org.quartz.core.SchedulerSignalerImpl
INFO: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
Dec 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler
INFO: Quartz Scheduler v.2.1.6 created.
Dec 21, 2012 9:59:45 AM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Dec 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler initialize
INFO: Scheduler meta-data: Quartz Scheduler (v2.1.6) 'OpenEJB-TimerService-Scheduler' with instanceId 'OpenEJB'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.apache.openejb.core.timer.DefaultTimerThreadPoolAdapter' - with 0 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
Dec 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'OpenEJB-TimerService-Scheduler' initialized from an externally provided properties instance.
Dec 21, 2012 9:59:45 AM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: 2.1.6
Dec 21, 2012 9:59:45 AM org.quartz.core.QuartzScheduler start
INFO: Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB started.
Dec 21, 2012 9:59:45 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created Ejb(deployment-id=ScheduleEJB, ejb-name=ScheduleEJB, container=My Singleton Container)
Dec 21, 2012 9:59:45 AM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Started Ejb(deployment-id=ScheduleEJB, ejb-name=ScheduleEJB, container=My Singleton Container)
The EJB 3.1 specification addresses this problem by removing the restriction that enterprise bean classes must be packaged in an ejb-jar file. You now have the option of placing EJB classes directly in the .war file, using the same packaging guidelines that apply to web application classes.
You can, however, include one EJB 2.1 project in an EAR 5.0 project, and add a Startup Bean in this EJB 2.1 project, which will execute at Application Startup. Snippet from ejb-jar.xml
Attribute default: FALSE (initialize EJB type when EJB is first used by application) for beans other than message-driven beans. Always TRUE for message-driven beans.
You can configure EJBs so that they are initialized at application start time by changing a setting in the Administrative Console (see Related URL: Changing enterprise bean types to initialize at application start time using the administrative console).
Did you already have a look to TomEE examples page? There is a similar example which actually running.
http://openejb.apache.org/examples-trunk/schedule-methods/README.html
Maybe you could give it a try and check what is actually different with yours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With