Issue with Quartz persistent jobs while using with Spring

I have solved the problem by replacing MethodInvokingJobDetailFactoryBean with JobDetailFactoryBean. Configuration for the same is as follows:

<bean name="myJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
    <property name="jobClass" value="mypackage.MyJob" />
    <property name="group" value="MY_JOBS_GROUP" />
    <property name="durability" value="true" />
</bean>

However, to Autowire the spring managed beans in my job class mypackage.MyJob, I have added the following as first line in my execute method:

class MyJob implements Job {
    ...
    public void execute(final JobExecutionContext context) throws JobExecutionException {
        // Process @Autowired injection for the given target object, based on the current web application context. 
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        ...
    }

}

Hope it it will help someone else facing the same issue.


When you are using persistent quartz jobs, you should be setting the org.quartz.jobStore.useProperties property to true. That forces the job data to be saved as Strings instead of Java Serialized objects.

Doing so however may cause some problems with Spring, that are easily solvable.

Check these links for more details:

http://site.trimplement.com/using-spring-and-quartz-with-jobstore-properties/

http://forum.spring.io/forum/spring-projects/container/121806-quartz-error-ioexception