Announcement Announcement Module
Collapse
No announcement yet.
Quartz 1.6.4, JdbcStore and MethodInvokingJobDetailFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz 1.6.4, JdbcStore and MethodInvokingJobDetailFactoryBean

    Hi,
    I have a problem, using Quartz, with a jdbc store.
    If I use the RAMJobStore in SchedulerFactoryBean things work like a charm, but if I change it to postgres, it throws an exception:
    Caused by: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean

    I've already read: SPR-2850 and SPR-3019 , but my problem is different.
    Also changing org.quartz.jobStore.useProperties from false to true, causes other exception about can't put an object into a property.

    Does anybody has a clue about what can be causing it? My stack trace and config below.
    Thanks

    spring.cgf.xml:

    <bean id="reminderScheduler" class="org.unam.mcic.metrics.job.ReminderScheduler " />

    <bean id="dailyReminderScheduler" class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean"
    autowire="no">
    <property name="targetObject" ref="reminderScheduler" />
    <property name="targetMethod" value="scheduleForToday" />
    </bean>

    <bean id="dailyReminderSchedulerCron" class="org.springframework.scheduling.quartz.CronT riggerBean" >
    <property name="jobDetail" ref="dailyReminderScheduler"/>
    <property name="cronExpression" value="0 * * * * ?"/>
    </bean>

    RAM configuration (works well, but can't save to db):

    <bean id="Scheduler"
    class="org.springframework.scheduling.quartz.Sched ulerFactoryBean" lazy-init="false" autowire="no">
    <property name="autoStartup"><value>true</value></property>
    <property name="applicationContextSchedulerContextKey"><valu e>applicationContext</value></property>
    <property name="waitForJobsToCompleteOnShutdown"><value>true </value></property>
    <property name="quartzProperties">
    <props>
    <!-- ThreadPool -->
    <prop key="org.quartz.threadPool.class">org.quartz.simpl .SimpleThreadPool</prop>
    <prop key="org.quartz.threadPool.threadCount">5</prop>
    <prop key="org.quartz.threadPool.threadPriority">5</prop>
    <!-- Job store -->
    <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
    <prop key="org.quartz.jobStore.class">org.quartz.simpl.R AMJobStore</prop>
    </props>
    </property>
    <property name="triggers">
    <list>
    <ref local="dailyReminderSchedulerCron"/>
    </list>
    </property>

    JDBCstore configuration (causes exeption):
    <bean id="Scheduler"
    class="org.springframework.scheduling.quartz.Sched ulerFactoryBean" lazy-init="false" autowire="no">
    <property name="dataSource" ref="dataSource" />
    <property name="autoStartup"><value>true</value></property>
    <property name="applicationContextSchedulerContextKey"><valu e>applicationContext</value></property>
    <property name="waitForJobsToCompleteOnShutdown"><value>true </value></property>
    <property name="quartzProperties">
    <props>
    <!-- ThreadPool -->
    <prop key="org.quartz.threadPool.class">org.quartz.simpl .SimpleThreadPool</prop>
    <prop key="org.quartz.threadPool.threadCount">5</prop>
    <prop key="org.quartz.threadPool.threadPriority">5</prop>
    <!-- Job store -->
    <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
    <prop key="org.quartz.jobStore.class">org.quartz.impl.jd bcjobstore.JobStoreTX</prop>
    <prop key="org.quartz.jobStore.driverDelegateClass">org. quartz.impl.jdbcjobstore.PostgreSQLDelegate</prop>
    <prop key="org.quartz.jobStore.useProperties">false</prop>
    <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
    </props>
    </property>
    <property name="triggers">
    <list>
    <ref local="dailyReminderSchedulerCron"/>
    </list>
    </property>



    The stack trace:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'Scheduler' defined in class path resource [spring-quartz.cfg.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean]
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4350)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)
    Caused by: org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.store Job(JobStoreSupport.java:1106)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$4.exe cute(JobStoreSupport.java:1076)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.ex ecute(JobStoreSupport.java:3688)
    at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeIn Lock(JobStoreCMT.java:244)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.execu teInLock(JobStoreSupport.java:3684)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.store Job(JobStoreSupport.java:1072)
    at org.quartz.core.QuartzScheduler.addJob(QuartzSched uler.java:814)
    at org.quartz.impl.StdScheduler.addJob(StdScheduler.j ava:288)
    at org.springframework.scheduling.quartz.SchedulerAcc essor.addJobToScheduler(SchedulerAccessor.java:317 )
    at org.springframework.scheduling.quartz.SchedulerAcc essor.addTriggerToScheduler(SchedulerAccessor.java :340)
    at org.springframework.scheduling.quartz.SchedulerAcc essor.registerJobsAndTriggers(SchedulerAccessor.ja va:276)
    at org.springframework.scheduling.quartz.SchedulerFac toryBean.afterPropertiesSet(SchedulerFactoryBean.j ava:483)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1335)
    ... 30 more
    Caused by: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.seria lizeJobData(StdJDBCDelegate.java:3358)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.inser tJobDetail(StdJDBCDelegate.java:515)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.store Job(JobStoreSupport.java:1103)
    ... 43 more

    The exception with org.quartz.jobStore.useProperties set to true:
    Caused by: java.io.IOException: JobDataMap values must be Strings when the 'useProperties' property is set. Key of offending value: methodInvoker

  • #2
    If I remember correctly, MethodInvokingJobDetail cannot be stored in the database because it is not Serializable. Period.

    Comment

    Working...
    X