-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Hello all,
I'm working on a task which implies to upgrade our project from Spring 5 to Spring 6. I found the following error/issue when a quartz job is creating and scheduled at runtime:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.project.JobTask': Unsatisfied dependency expressed through method 'setMapWithEnumKeys' parameter 0: No qualifying bean of type 'java.util.Map<com.project.EnumKeyJobTask, com.project.EnumValueJobTask>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:896) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:849) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:328) at org.springframework.scheduling.quartz.SpringBeanJobFactory.createJobInstance(SpringBeanJobFactory.java:89) at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:43) ... 2 common frames omitted
The definition of mapWithEnumKeys bean is following:
<util:map id="mapWithEnumKeys" map-class="java.util.HashMap"> <entry key="ENUM_KEY_A" value-ref="EnumValueJobTaskA"/> <entry key="ENUM_KEY_B" value-ref="EnumValueJobTaskB"/> <entry key="ENUM_KEY_C" value-ref="EnumValueJobTaskC"/> <entry key="ENUM_KEY_D" value-ref="EnumValueJobTaskD"/> </util:map>
The setter from Job Task looks like following:
@Autowired public void setMapWithEnumKeys(Map<EnumKeyJobTask, EnumValueJobTask> mapWithEnumKeys) { this.mapWithEnumKeys = mapWithEnumKeys; }
The SpringBeanJobFactory type is used for our bean type instance for jobFactory from schedulerFactory definition.
<property name="jobFactory"> <bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" /> </property>
I'm thinking is an issue regarding to the new Autowire Capability implemented in Spring 5 for Quartz Beans. Because for a normal bean definition in XML everything works fine:
<property name="mapWithEnumKeys" ref="mapWithEnumKeys" />
I tried to use key-type attribute for util:map bean definition but I got the same issue.
Spring version 6.2.11
Quartz Scheduler 2.5.0