title: Creating multiple SchedulerFactoryBean in Quartz
body: <p>I have run into a problem where I have two classes extending <code>QuartzJobBean</code>. The problem I am facing is to create two <code>SchedulerFactoryBean</code>. I did my research and found that setting the property <code>schedulerName</code> solves the problem. This did not work for me. I used <code>@Qualifier</code> also. If I create the two beans of <code>SchedulerFactoryBean</code> , Spring doesn't know which scheduler to refer to. I have two CronTriggers. </p>
  
  <p>Code:</p>
  
  <pre><code>&lt;!--
     &lt;bean name="quartzSchedulerR" class="org.springframework.scheduling.quartz.JobDetailBean"&gt;
          &lt;property name="jobClass" value="com.task.QuartzScheduler" /&gt;
          &lt;property name="jobDataAsMap"&gt;
              &lt;map&gt;
                  &lt;entry key="rRSImpl" value-ref="rRSService"  /&gt;
                  &lt;entry key="SRObject" value-ref="SRObject"/&gt;
              &lt;/map&gt;
          &lt;/property&gt;
      &lt;/bean&gt; 
  
          &lt;bean id="cronTriggerR"
              class="org.springframework.scheduling.quartz.CronTriggerBean"&gt;
  
              &lt;property name="jobDetail" ref="quartzSchedulerR" /&gt;
              &lt;property name="cronExpression" value="0 30 12 ? * MON *" /&gt;
  
      &lt;/bean&gt;
  
          &lt;bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"&gt;
          &lt;property name="schedulerName" value="scheduleOne"/&gt;
          &lt;property name="schedulerContextAsMap"&gt;
              &lt;map&gt;
              &lt;entry key="rSchedulerServiceImpl" value-ref="rSchedulerServiceImpl"&gt;&lt;/entry&gt;
              &lt;/map&gt;
          &lt;/property&gt;
          &lt;property name="jobDetails"&gt;
             &lt;list&gt;
                &lt;ref bean="quartzSchedulerR" /&gt;
             &lt;/list&gt;
          &lt;/property&gt;
  
          &lt;property name="triggers"&gt;
              &lt;list&gt;
              &lt;ref bean="cronTriggerR" /&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  
          &lt;/bean&gt; --&gt;
  
          &lt;bean id ="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"&gt;
              &lt;property name="schedulerContextAsMap"&gt;
                      &lt;map&gt;
                      &lt;entry key="rSSImpl" value-ref="rSSImpl"&gt;&lt;/entry&gt;
                      &lt;/map&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
  
  
          &lt;bean id="jobDetailFactory" class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"&gt;
          &lt;property name="targetBeanName"&gt;
              &lt;idref local="jobDetail" /&gt;
          &lt;/property&gt;
  
          &lt;/bean&gt;
  
          &lt;bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean" scope="prototype"&gt;
          &lt;property name="jobClass" value="com.scheduler.SMTPMailJob " /&gt;
  
           &lt;property name="jobDataAsMap"&gt;
              &lt;map&gt;
                &lt;entry key="rSSeImpl" value-ref="rSSImpl" /&gt;
                &lt;entry key="fUtil" value-ref="fUtil" /&gt;
                &lt;entry key="rService" value-ref="rService" /&gt;
                &lt;entry key="fusion" value-ref="fusion"/&gt;
                &lt;entry key="fcproperties" value-ref="fcproperties"/&gt;
               &lt;/map&gt;
            &lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;bean id="jobTriggerFactory"
          class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"&gt;
          &lt;property name="targetBeanName"&gt;
              &lt;idref local="jobTrigger" /&gt;
          &lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;bean id="jobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"
          scope="prototype"&gt;
          &lt;/bean&gt;
  </code></pre>
  
  <p>Currently I comment out the first scheduler and the application works as expected. But if I uncomment it, the second scheduler stops working. Any workaround for this issue.. ? Any help is appreciated.</p>
  
  <p><strong>EDIT:</strong> There is no error but I know that the job isn't scheduled. The error is basically that spring doesn't find a unique bean for <code>com.quartz.Scheduler</code> when both the <code>SchedulerFactoryBean</code> are defined. Basically how to configure multiple <code>SchedulerFactoryBean</code> for totally isolated classes.. ? </p>