0

I have two different applications which has different spring quartz jobs configured. First application has 2 jobs and second application has 1 job. And I am pointing to same oracle database schema from both applications. Since oracle data source is same, all three job triggers are inserted into QRTZ_CRON_TRIGGERS. But if I start second application, it starts triggering other applications job and failed with issue no class found since application1 job classes are not in second application. Please help if I am doing something wrong here.

First application has following configuration:

<bean id="syncScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="dataSource">
        <ref bean="oracleDatasource" />
    </property>
    <property name="quartzProperties">
        <props>
            <prop key="org.quartz.scheduler.instanceName">SyncScheduler</prop>
            <prop key="org.quartz.jobStore.isClustered">true</prop>
            <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop>
            <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
            <prop key="org.quartz.jobStore.clusterCheckinInterval">60000</prop>
            <prop key="org.quartz.jobStore.misfireThreshold">600000</prop>
            <prop key="org.quartz.scheduler.idleWaitTime">3000000</prop>
            <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
            <prop key="org.quartz.jobStore.tablePrefix">notification</prop>

            <!-- <prop key="org.quartz.threadPool.threadCount">3</prop> -->
        </props>
    </property>
    <property name="jobDetails">
        <list>
            <ref bean="app1Job1" />
            <ref bean="app1Job2" />
        </list>
    </property>
    <property name="triggers">
        <list>
            <ref bean="app1Job1Trigger1" />
            <ref bean="app1Job1Trigger2" />
        </list>
    </property>
</bean>

And Other application has 1 job but this app is also pointing to same oracle data source which is 'oracleDatasource':

<bean id="syncScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource">
    <ref bean="oracleDatasource" />
</property>
<property name="quartzProperties">
    <props>
        <prop key="org.quartz.scheduler.instanceName">SyncScheduler</prop>
        <prop key="org.quartz.jobStore.isClustered">true</prop>
        <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop>
        <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
        <prop key="org.quartz.jobStore.clusterCheckinInterval">60000</prop>
        <prop key="org.quartz.jobStore.misfireThreshold">600000</prop>
        <prop key="org.quartz.scheduler.idleWaitTime">3000000</prop>
        <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
        <prop key="org.quartz.jobStore.tablePrefix">notification</prop>

        <!-- <prop key="org.quartz.threadPool.threadCount">3</prop> -->
    </props>
</property>
<property name="jobDetails">
    <list>
        <ref bean="app2Job1" />  
    </list>
</property>
<property name="triggers">
    <list>
        <ref bean="app2Job1Trigger1" />
    </list>
</property>

Narendra Verma
  • 2,372
  • 6
  • 34
  • 61
  • 1
    Hey Jarrod, I read the link you have given. I do not see any link of question with link you provided. I am not sure why did you mark this duplicate.. It Quartz specific issue. I already mentioned I am initializing two different app and pointing to same data source. I think you should read my whole question before actually marking this duplicate. – Narendra Verma Feb 22 '17 at 18:52
  • maybe you can try to use different tablePrefix for each application. The quartz tutorial says "Using different prefixes may be useful for creating multiple sets of tables, for multiple scheduler instances, within the same database", Although I see you already defined it as "notification" so I'm not sure why your table name is "QRTZ_CRON_TRIGGERS". – yishaiz Feb 27 '17 at 09:16
  • And anyway, clearly its not a duplicate of the linked question. – yishaiz Feb 27 '17 at 09:17
  • @Yishaiz Thanks for the response. Yes, I did follow this approach before your comment and this worked for me. I had left with two options, either use tables with different prefix or use altogether different quartz schema. I went with first one. – Narendra Verma Mar 08 '17 at 13:11
  • Hey Jarrod, do you still see this is duplicate question? Even Yishaiz mentioned, its not a duplicate one. – Narendra Verma Mar 08 '17 at 13:12
  • try to do [this](http://stackoverflow.com/help/reopen-questions) – yishaiz Mar 08 '17 at 14:20
  • Facing similar issue, can I not use the quartz tables with the same prefix within the same schema for both the apps? – praveen_mohan Mar 29 '22 at 08:59

0 Answers0