This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Description
If you define a bean that implements SchwartzJob as prototype scoped in resources.groovy
'testJob'(TestJob) { bean ->
bean.scope = 'prototype'
}
You will get the following on startup:
The dependencies of some of the beans in the application context form a cycle:
┌─────┐
| testJob (field private com.agileorbit.schwartz.QuartzService schwartztest.TestJob.com_agileorbit_schwartz_SchwartzJob__quartzService)
↑ ↓
| schwartzQuartzService (field protected com.agileorbit.schwartz.SchwartzJob[] com.agileorbit.schwartz.QuartzService.jobs)
└─────┘
I guess in the singleton case, the beans injected into the job array don't need to be initialize again, so it works.
The fix is simple, the quartzService reference in SchwartzJob just needs to be annotated with @Lazy:
@Lazy @Autowired QuartzService quartzService
Simple project to reproduce:
https://github.com/longwa/grails-schwartzTest