michaelklishin / quartz-mongodb

A MongoDB-based store for the Quartz scheduler. This fork strives to be as feature complete as possible. Originally by MuleSoft.
Other
249 stars 203 forks source link

Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean #145

Closed wqe146273123 closed 6 years ago

wqe146273123 commented 7 years ago

use spring boot quartz 2.2.3 quartz-mongodb but appear:Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean

this is my config class: @Bean("schedulerFactory") public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean(); Resource resource = new ClassPathResource("jobstore.properties"); schedulerFactory.setConfigLocation(resource);

    MethodInvokingJobDetailFactoryBean JobDetailFactory = new MethodInvokingJobDetailFactoryBean();
    JobDetailFactory.setName("test");
    JobDetailFactory.setTargetObject(app.getbean("testJob"));
    JobDetailFactory.setTargetMethod("work");
    JobDetailFactory.setConcurrent(false);
    try {
        JobDetailFactory.afterPropertiesSet();
    } catch (ClassNotFoundException | NoSuchMethodException e1) {
        e1.printStackTrace();
    }
    JobDetail jobDetail = JobDetailFactory.getObject();

    CronTriggerFactoryBean cronTriggerFactoryBean  = new CronTriggerFactoryBean ();
    cronTriggerFactoryBean.setJobDetail(jobDetail);
    cronTriggerFactoryBean.setCronExpression("0/20 * * * * ?");
    cronTriggerFactoryBean.setName("test");
    try {
        cronTriggerFactoryBean.afterPropertiesSet();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    CronTrigger cronTrigger = cronTriggerFactoryBean.getObject();
    schedulerFactory.setTriggers(cronTrigger);
    return schedulerFactory;
}
michaelklishin commented 6 years ago

Quartz stores assume that the job context map they are given can be serialised.

lxwhappy commented 5 years ago

hello,i am have the same exception,finally,how solved?

michaelklishin commented 5 years ago

Quartz stores assume that the job context map they are given can be serialised.

so you can only use values that can be serialised (as in Java's built-in serialisation) in job context maps.