title: How to use SchedulerFactoryBean.schedulerContextAsMap with javaconfig
body: <p>I use Spring 4.0 and have moved a project from xml to java-config, and everything works except accessing an <code>@Service("scheduleService")</code> annotated class from <code>QuartzJobBean.executeInternal</code>.</p>
  
  <p>The xml-bit I had to make it work was:</p>
  
  <pre><code>&lt;bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;
      &lt;property name="schedulerContextAsMap"&gt;
          &lt;map&gt;
              &lt;entry key="scheduleService" value-ref="scheduleService" /&gt;
              &lt;entry key="knxUtil" value-ref="knxUtil" /&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Then, for scheduling the Job inside <code>@Service("scheduleService")</code> I used:</p>
  
  <pre><code>JobBuilder jobBuilder = JobBuilder.newJob(ScheduledActionRunner.class)
  </code></pre>
  
  <p>Furthermore, to actually execute the <code>Job</code> I had it working like this:</p>
  
  <pre><code>@Component
  public class ScheduledActionRunner extends QuartzJobBean {
  
      private KNXUtil         knxUtil;
  
      private ScheduleService scheduleService;
  
      public ScheduledActionRunner() {
      }
  
      @Autowired
      public void setScheduleService(ScheduleService scheduleService) {
          this.scheduleService = scheduleService;
      }
  
      @Autowired
      public void setKnxUtil(KNXUtil knxUtil) {
          this.knxUtil = knxUtil;
      }
  
      @Override
      public void executeInternal(JobExecutionContext context) throws JobExecutionException {
  
          JobDataMap jobDataMap = context.getMergedJobDataMap();
  
          String scheduleId = jobDataMap.getString("scheduleId");
  
          Schedule schedule = scheduleService.get(scheduleId);
  
          Set&lt;ScheduledAction&gt; actions = schedule.getScheduledActions();
  
          for (ScheduledAction scheduledAction : actions) {
              scheduledAction.getAction().execute(logger, knxUtil);
          }
  
      }
  </code></pre>
  
  <p>As mentioned above, all this used to work while using xml-configuration.</p>
  
  <p>Now, with java-config, it fails with <code>NullPointerException</code> at <code>scheduleService.get(scheduleId);</code></p>
  
  <p>For java-configuration I set up the <code>SchedulerFactoryBean</code> like this:</p>
  
  <pre><code>@Configuration
  @PropertySource(value = "classpath:properties.${target_env:dev}.properties")
  @ComponentScan(basePackages = { "com.example.smart" }
  public class SpringRootApplication {
  
      @Autowired
      private ScheduleService scheduleService;
  
      @Autowired
      private KNXUtil         knxUtil;
  
      @Bean
      SchedulerFactoryBean schedulerFactoryBean() {
  
          SchedulerFactoryBean bean = new SchedulerFactoryBean();
  
          Map&lt;String, Object&gt; schedulerContextAsMap = new HashMap&lt;String, Object&gt;();
          schedulerContextAsMap.put("scheduleService", scheduleService);
          schedulerContextAsMap.put("knxUtil", knxUtil);
  
          bean.setSchedulerContextAsMap(schedulerContextAsMap);
  
          return bean;
      }
  }
  </code></pre>
  
  <p>How can I insert the reference to <code>scheduleService</code> inside the <code>schedulerContextAsMap</code> using java-config?</p>