Exception while instantiating job Quartz

Im trying to use Quartz with spring boot and I’m getting this exception :

2021-04-01 19:07:25.753 ERROR 13088 — [SchedulerThread] org.quartz.core.ErrorLogger : An error occured instantiating job to be executed. job= ‘ecadb474-77b7-45bd-926a-caee31728465’

org.quartz.SchedulerException: Problem instantiating class ‘ClassJob’ – at org.quartz.core.JobRunShell.initialize(JobRunShell.java:135) ~[quartz-2.2.0.jar:na] at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:378) [quartz-2.2.0.jar:na] Caused by: java.lang.AbstractMethodError: config.AutowiringSpringBeanJobFactory.newJob(Lorg/quartz/spi/TriggerFiredBundle;Lorg/quartz/Scheduler;)Lorg/quartz/Job; at org.quartz.core.JobRunShell.initialize(JobRunShell.java:128) ~[quartz-2.2.0.jar:na] … 1 common frames omitted

Here is my code : ClassJob :

@Component
public class ClassJob extends QuartzJobBean {

    private static final Logger logger = LoggerFactory
        .getLogger(ClassJob.class);

    @Override
    public void executeInternal(JobExecutionContext jobExecutionContext)
        throws JobExecutionException {
        logger
            .info(
                "Executing Job with key {}",
                jobExecutionContext.getJobDetail().getKey());


        JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
        int controlRuleNum = jobDataMap.getInt("controlRuleNum");

        executeRule(controlRuleNum);
    }

    private void executeRule(int ebControlRuleNum) {
        System.out.println(ebControlRuleNum);
    }

}

Configuration :

@Configuration
public class QuartzSchedulerConfiguration {
    @Autowired
    ApplicationContext applicationContext;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @PostConstruct
    public void init() {
        logger.debug("QuartzConfig initialized.");
    }

    @Bean
    public SchedulerFactoryBean scheduler() {
        SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean();

        AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
        jobFactory.setApplicationContext(applicationContext);
        quartzScheduler.setJobFactory(jobFactory);

        return quartzScheduler;
    }

    @Bean
    public JobFactory jobFactory() {
        return new AutowiringSpringBeanJobFactory();
    }
}
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory
    implements ApplicationContextAware {

    @Autowired
    private AutowireCapableBeanFactory autowireCapableBeanFactory;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext)
        throws BeansException {
        autowireCapableBeanFactory = applicationContext
            .getAutowireCapableBeanFactory();
    }

  @Override
    public Object createJobInstance(final TriggerFiredBundle bundle) {
    final Object job = super.createJobInstance(bundle);
    autowireCapableBeanFactory.autowireBean(job);
        autowireCapableBeanFactory
            .initializeBean(job, job.getClass().getName());
    return job;
  }

}
    private void scheduleJob(int ebControlRuleNum, Date date) {

        try {
            JobDataMap jobDataMap = new JobDataMap();
            jobDataMap.put("controlRuleNum", ebControlRuleNum);

            JobDetail jobDetail = JobBuilder
                .newJob(ClassJob.class)
                .withIdentity(UUID.randomUUID().toString(), "controlRule-jobs")
                .withDescription("call control rule Job")
                .usingJobData(jobDataMap).storeDurably().build();

            Trigger trigger = TriggerBuilder
                .newTrigger().forJob(jobDetail)
                .withIdentity(
                    jobDetail.getKey().getName(),
                    "controlRule-triggers")
                .withDescription("controlRule Trigger").startAt(date)

                .build();

            SchedulerFactory sf = new StdSchedulerFactory();
            Scheduler scheduler = sf.getScheduler();
            scheduler.start();
            scheduler.scheduleJob(jobDetail, trigger);
        } catch (SchedulerException ex) {
            logger.error("Error scheduling email", ex);
        }

    }

Can someone point out where am I going wrong?

Answer

For future references, I added “spring-context-support” dependency and it worked