I have configured a spring's method invoking job previously which is working fine. Now my requirement is to have this job as persistent which will run in a clustered environment.
After configuring the quartz as clustered and persistence, application is throwing the following exception at deployment:
java.io.NotSerializableException: Unable to serialize JobDataMap for
insertion into database because the value of property 'methodInvoker'
is not serializable:
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
I am using the following versions:
- Spring version 3.1.4.RELEASE
- Quartz version 2.1.7
Update: As per the documentation of MethodInvokingJobDetailFactoryBean
:
JobDetails created via this FactoryBean are not serializable.
So, looking for some alternative approach to configure a persistent job in spring.
Best Answer
I have solved the problem by replacing
MethodInvokingJobDetailFactoryBean
withJobDetailFactoryBean
. Configuration for the same is as follows:However, to
Autowire
the spring managed beans in my job classmypackage.MyJob
, I have added the following as first line in my execute method:Hope it it will help someone else facing the same issue.