调度 java 后台作业时出现 JobRunr 异常

JobRunrException when scheduling java background job

我们正在使用 JobRunr 在 Java 中进行一些后台作业处理。

我们按如下方式排列作业:

CalendarEntry calendarEntry = new CalendarEntry("Quatuor Ebène", LocalDateTime.of(2020, 9, 16, 20, 0, 0).toInstant(ZoneOffset.UTC));
jobScheduler.enqueue(() -> calendarService.createCalendarEntry(calendarEntry));

安排作业时,我们收到以下异常...知道发生了什么吗?

Did you register all necessary Jackson Modules?
org.jobrunr.JobRunrException: Did you register all necessary Jackson Modules?
    at org.jobrunr.JobRunrException.configurationException(JobRunrException.java:56)
    at org.jobrunr.utils.mapper.jackson.JacksonJsonMapper.deserialize(JacksonJsonMapper.java:76)
    at org.jobrunr.jobs.mappers.JobMapper.deserializeJob(JobMapper.java:20)
    at org.jobrunr.storage.InMemoryStorageProvider.deepClone(InMemoryStorageProvider.java:243)
    at org.jobrunr.storage.InMemoryStorageProvider.saveJob(InMemoryStorageProvider.java:259)
    at org.jobrunr.storage.InMemoryStorageProvider.save(InMemoryStorageProvider.java:109)
    at org.jobrunr.scheduling.JobScheduler.saveJob(JobScheduler.java:406)
    at org.jobrunr.scheduling.JobScheduler.enqueue(JobScheduler.java:397)
    at org.jobrunr.scheduling.JobScheduler.enqueue(JobScheduler.java:79)
    at org.jobrunr.scheduling.BackgroundJob.enqueue(BackgroundJob.java:39)
    at be.es.eventsystem.calendar.CalendarService.createCalendarEntry(CalendarService.java:106)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `be.es.eventsystem.calendar.CalendarEntry` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (String)"{"version":0,"jobSignature":"CalendarService.createCalendarEntry(CalendarEntry)","jobName":"CalendarService.createCalendarEntry(be.es.eventsystem.calendar.CalendarEntry@ea7ae0ea)","jobDetails":{"className":"be.es.eventsystem.calendar.CalendarService","staticFieldName":null,"methodName":"createCalendarEntry","jobParameters":[{"className":"be.es.eventsystem.calendar.CalendarEntry","object":{"@class":"be.es.eventsystem.calendar.CalendarEntry","title":"Quatuor Ebène","eventDate":"2020-09-16T20:00:00Z","id":"bc8ad3db-cf89-49b6-a382-8b3a08c3cbd2"}}]},"id":"43a6e74a-4b53-4227-9985-4daf0005abc7","jobHist"[truncated 182 chars]; line: 1, column: 358] (through reference chain: org.jobrunr.jobs.Job["jobDetails"]->org.jobrunr.jobs.JobDetails["jobParameters"]->java.util.ArrayList[0]->org.jobrunr.jobs.JobParameter["object"])
    at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
    at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1615)
    at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
    at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1077)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1332)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:199)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)

我认为原因是您的 CalendarEntry class 没有默认构造函数,这是必需的,因为 Jackson 将尝试反序列化它。