mongodb-quartz-net
mongodb-quartz-net copied to clipboard
Several exceptions related to GetJobDetail()
Afaik, the GetJobDetail()
is supposed to return null for invalid jobs. In 3.1.0 (and 4.0.0-preview.3) the GetJobDetail() method raises exceptions instead of returning null in a few cases. While this can be handled when calling GetJobDetails()
directly, it causes some internal errors during scheduler initialization as well.
Scenarios: Job class no longer exists
After removing a job class or changing its class name and restarting the scheduler, the GetJobDetail() raises an exception with the following error.
Quartz.JobPersistenceException: Job class cannot be null.
---> System.ArgumentException: Job class cannot be null.
at Quartz.Impl.JobDetailImpl.set_JobType(Type value)
at Quartz.Impl.JobDetailImpl..ctor(JobKey key, Type jobType, String description, Boolean isDurable, Boolean requestsRecovery, JobDataMap jobDataMap, Nullable`1 disallowConcurrentExecution, Nullable`1 persistJobDataAfterExecution)
at Quartz.JobBuilder.Build()
at Quartz.Spi.MongoDbJobStore.Models.JobDetail.GetJobDetail()
at Quartz.Spi.MongoDbJobStore.MongoDbJobStore.ReplaceTriggerInternal(TriggerKey triggerKey, IOperableTrigger newTrigger)
at Quartz.Spi.MongoDbJobStore.MongoDbJobStore.ReplaceTrigger(TriggerKey triggerKey, IOperableTrigger newTrigger, CancellationToken token)
--- End of inner exception stack trace ---
at Quartz.Spi.MongoDbJobStore.MongoDbJobStore.ReplaceTrigger(TriggerKey triggerKey, IOperableTrigger newTrigger, CancellationToken token)
at Quartz.Core.QuartzScheduler.RescheduleJob(TriggerKey triggerKey, ITrigger newTrigger, CancellationToken cancellationToken)
at Quartz.Xml.XMLSchedulingDataProcessor.ScheduleJobs(IScheduler sched, CancellationToken cancellationToken)
at Quartz.ServiceCollectionSchedulerFactory.InitializeScheduler(IScheduler scheduler, CancellationToken cancellationToken)
at Quartz.ServiceCollectionSchedulerFactory.GetScheduler(CancellationToken cancellationToken)
JobDataMap difference between v3 and v4
An empty JobDataMap is stored as "{}"
in v4.0.0-preview.3 and null
in v3.1.0. Because of this migrating from v3.1.0 to v4.0.0-preview.3 with existing jobs in the mongodb store causes the following error:
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'newJobDataMap')
at Quartz.JobBuilder.SetJobData(JobDataMap newJobDataMap)
at Quartz.Spi.MongoDbJobStore.Models.JobDetail.GetJobDetail()
at Quartz.Spi.MongoDbJobStore.MongoDbJobStore.RetrieveJob(JobKey jobKey, CancellationToken token)
at Quartz.Xml.XMLSchedulingDataProcessor.ScheduleJobs(IScheduler sched, CancellationToken cancellationToken)
at Quartz.ServiceCollectionSchedulerFactory.InitializeScheduler(IScheduler scheduler, CancellationToken cancellationToken)
at Quartz.ServiceCollectionSchedulerFactory.GetScheduler(CancellationToken cancellationToken)