tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo K. Shikida" <shik...@gmail.com>
Subject singleton initializing twice? (1.6.0-stable)
Date Mon, 28 Sep 2015 19:16:08 GMT
Hi

I have a singleton that initialized my own scheduler.

Please don't ask me why do I need another schedule, since TomEE already
provides one by default. Actually, I need this because since the JavaEE
spec is not clear about how the timers must be hadled when they're
persistent, I had to do this. But anyway.


@Startup
@Singleton
@DependsOn("SystemInitializerEJB")
public class TimerEJB{

    private Scheduler scheduler;

    private static Logger log = Logger.getLogger(TimerEJB.class);

    @PostConstruct
    public void initialize() throws SchedulerException{
        log.info("Initialize "+this);
        StdSchedulerFactory factory = new StdSchedulerFactory();

factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
        scheduler = factory.getScheduler();
        scheduler.start();
        log.info("scheduler "+scheduler.getMetaData().getSchedulerName());
    }


SOMETIMES...

it seems to be initialized twice, because I get this message

INFO: Started Ejb(deployment-id=SystemInitializerEJB,
ejb-name=SystemInitializerEJB, container=Default Singleton Container)

2015-09-28 17:40:02,806 INFO   [TimerEJB] Initialize
com.company.software.tomee.timer.TimerEJB@4d8818cd
2015-09-28 17:40:02,807 INFO   [TimerEJB] Initialize
com.company.software.tomee.timer.TimerEJB@7e2715a4 Sep 28, 2015 5:40:02 PM
org.quartz.impl.StdSchedulerFactory instantiate
INFO: Using default implementation for ThreadExecutor
Sep 28, 2015 5:40:02 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Using default implementation for ThreadExecutor
Sep 28, 2015 5:40:02 PM org.quartz.core.SchedulerSignalerImpl <init>
INFO: Initialized Scheduler Signaller of type: class
org.quartz.core.SchedulerSignalerImpl
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler <init>
INFO: Quartz Scheduler v.2.2.0 created.
Sep 28, 2015 5:40:02 PM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler initialize
INFO: Scheduler meta-data: Quartz Scheduler (v2.2.0)
'MyClusteredScheduler2' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 30 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support
persistence. and is not clustered.

Sep 28, 2015 5:40:02 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'MyClusteredScheduler2' initialized from an
externally opened InputStream.
Sep 28, 2015 5:40:02 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: 2.2.0
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler start
INFO: Scheduler MyClusteredScheduler2_$_NON_CLUSTERED started.

2015-09-28 17:40:02,847 INFO   [TimerEJB] scheduler MyClusteredScheduler2
Sep 28, 2015 5:40:02 PM org.apache.openejb.assembler.classic.Assembler
startEjbs
INFO: Started Ejb(deployment-id=myTimerEJB, ejb-name=myTimerEJB,
container=Default Singleton Container)
Sep 28, 2015 5:40:02 PM org.quartz.core.SchedulerSignalerImpl <init>
INFO: Initialized Scheduler Signaller of type: class
org.quartz.core.SchedulerSignalerImpl
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler <init>
INFO: Quartz Scheduler v.2.2.0 created.
Sep 28, 2015 5:40:02 PM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler initialize
INFO: Scheduler meta-data: Quartz Scheduler (v2.2.0)
'MyClusteredScheduler2' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 30 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support
persistence. and is not clustered.

Sep 28, 2015 5:40:02 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'MyClusteredScheduler2' initialized from an
externally opened InputStream.
Sep 28, 2015 5:40:02 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: 2.2.0
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler MyClusteredScheduler2_$_NON_CLUSTERED shutting down.
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler standby
INFO: Scheduler MyClusteredScheduler2_$_NON_CLUSTERED paused.
Sep 28, 2015 5:40:02 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler MyClusteredScheduler2_$_NON_CLUSTERED shutdown complete.
Sep 28, 2015 5:40:02 PM
org.apache.openejb.core.transaction.EjbTransactionUtil handleSystemException
SEVERE: EjbTransactionUtil.handleSystemException: Scheduler with name
'MyClusteredScheduler2' already exists.
org.quartz.SchedulerException: Scheduler with name 'MyClusteredScheduler2'
already exists.
    at org.quartz.impl.SchedulerRepository.bind(SchedulerRepository.java:80)
    at
org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1352)
    at
org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1517)
    at
com.company.software.tomee.timer.TimerEJB.initialize(TimerEJB.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
    at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$LifecycleInvocation.invoke(ReflectionInvocationContext.java:214)
    at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
    at
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:180)
    at
org.apache.openejb.monitoring.StatsInterceptor.PostConstruct(StatsInterceptor.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:182)
    at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:164)
    at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:80)
    at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1565)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:175)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initializeDependencies(SingletonInstanceManager.java:166)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:173)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initializeDependencies(SingletonInstanceManager.java:166)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:173)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initializeDependencies(SingletonInstanceManager.java:166)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:173)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initializeDependencies(SingletonInstanceManager.java:166)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:173)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initializeDependencies(SingletonInstanceManager.java:166)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:173)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:116)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:114)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:125)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:91)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager.access$400(SingletonInstanceManager.java:67)
    at
org.apache.openejb.core.singleton.SingletonInstanceManager$Data.initialize(SingletonInstanceManager.java:367)
(...)

I can understand it seems to be like some dependency cycle, but I need to
know why it does not happen all the time and how to avoid this sort of
thing, because it really breaks the app.

Any help is welcome. thanks


[]

Leo

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message