Cannot use Spring autowire injection with Spring devtools

Open
#6,351 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
java, redis, spring
Domain
backend

Research direction

Reproduce the failure with Spring Devtools reload enabled using the WorkerOptions configuration shown. Start with SpringTasksInjector.java and the decode path in TasksRunnerService.java, then trace the reported autowiring failure. Done means the task runs successfully with Spring autowire injection while Devtools reload is active.

Written by the indexing model from the issue text.

Description

Redis version

5.0.13

Redisson version

3.40.2

Redisson configuration
WorkerOptions
                .defaults()
                .workers(4)
                .beanFactory(beanFactory)
                // Defines task timeout since task execution start moment
                .taskTimeout(60, TimeUnit.SECONDS)
                .addListener(
                    object : TaskFailureListener {
                        override fun onFailed(
                            taskId: String,
                            exception: Throwable,
                        ) {
                            Sentry.captureException(exception)
                            logger.error("Task $taskId failed", exception)
                        }
                    }
                )
What is the Expected behavior?

Task runs successfully

What is the Actual behavior?

o.s.b.f.NoSuchBeanDefinitionException: No qualifying bean of type 'com.claravine.aimia.integration.inbound.orchestration.IntegrationJobListener' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at o.s.b.f.s.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:2139)
at o.s.b.f.s.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1589)
at o.s.b.f.s.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1514)
at o.s.b.f.a.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:785)
... 16 common frames omitted
Wrapped by: <#5bd27f55> o.s.b.f.UnsatisfiedDependencyException: Error creating bean with name 'null': Unsatisfied dependency expressed through field 'integrationJobListener': No qualifying bean of type 'com.claravine.aimia.integration.inbound.orchestration.IntegrationJobListener' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at o.s.b.f.a.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788)
at o.s.b.f.a.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768)
at o.s.b.f.a.InjectionMetadata.inject(InjectionMetadata.java:146)
at o.s.b.f.a.AutowiredAnnotationBeanPostProcessor.processInjection(AutowiredAnnotationBeanPostProcessor.java:532)
at o.r.e.SpringTasksInjector.inject(SpringTasksInjector.java:38)
at o.r.e.TasksRunnerService.decode(TasksRunnerService.java:332)
... 11 common frames omitted
Wrapped by: <#4c799c21> j.l.IllegalStateException: Unable to initialize codec with ClassLoader parameter
at o.r.e.TasksRunnerService.decode(TasksRunnerService.java:337)
at o.r.e.TasksRunnerService.executeCallable(TasksRunnerService.java:205)
... 10 common frames omitted
Wrapped by: <#26055c7f> j.l.IllegalArgumentException: java.lang.IllegalStateException: Unable to initialize codec with ClassLoader parameter
at o.r.e.TasksRunnerService.executeCallable(TasksRunnerService.java:221)
at j.i.r.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at o.r.e.RedissonExecutorRemoteService.invokeMethod(RedissonExecutorRemoteService.java:106)
at o.r.RedissonRemoteService.lambda$executeMethod$14(RedissonRemoteService.java:453)
at j.u.c.Executors$RunnableAdapter.call(Unknown Source)

Additional information

This only happens when Spring Devtools reload is active

Dominant language
Java
Stars
24.4k
Forks
5.5k
Avg merge
4d 12h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from redisson/redisson

All issues in redisson/redisson

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.