Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple candidates for a Quartz' SchedulerFactoryBean #297

Closed
todorinskiz opened this issue May 14, 2020 · 0 comments · Fixed by #298
Closed

Multiple candidates for a Quartz' SchedulerFactoryBean #297

todorinskiz opened this issue May 14, 2020 · 0 comments · Fixed by #298

Comments

@todorinskiz
Copy link
Member

todorinskiz commented May 14, 2020

I'm submitting a

[X] bug report
[ ] feature request
[ ] question

Context

We are trying to create a hot fix module that can be deployed individually, without a dependency on Dynamic Extensions. It should also be able to co-exist with DE in order to be usable in our development & hosting environments.
Unfortunately, we ran into an issue, where multiple candidates for a Quartz' SchedulerFactoryBean, when applying both a DE amp that uses scheduling and our ALF-22094 hot fix AMP, causing NoUniqueBeanDefinitionException at startup.

https://github.com/xenit-eu/alfresco-hotfix-ALF-22094

Expected Behavior

Quartz Schedulers from different modules can coexist if:

  • They are marked as non-primary
  • They have unique bean qualifiers

Current Behavior

An exception is thrown, leaving the default Quartz scheduler not registered in the Spring context - thus it will not be used by Dynamic Extension Modules.

[ALFRESCO] 2020-05-13 14:01:23,487 ERROR [internal.activator.ContextLoaderListener] [localhost-startStop-1] Application context refresh failed (DynamicExtensionsApplicationContext(bundle=eu.xenit.de.control-panel, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'quartzTaskScheduler': Unsatisfied dependency expressed through bean property 'scheduler': : No qualifying bean of type [org.quartz.Scheduler] is defined: expected single matching bean but found 2: schedulerFactory,eu.xenit.alfresco.AntiIdleSchedulerFactoryBean; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.quartz.Scheduler] is defined: expected single matching bean but found 2: schedulerFactory,eu.xenit.alfresco.AntiIdleSchedulerFactoryBean

Possible Solution

Add qualifier annotation to both QuartzTaskScheduler and Quartz2TaskScheduler.
Register their beans as AbstractBeanDefinition.AUTOWIRE_BY_NAME instead of AbstractBeanDefinition.AUTOWIRE_BY_TYPE.

Steps to Reproduce

  1. Deploy the following modules
    1.1. Dynamic Extensions 2.0.3 or older
    1.2. https://github.com/xenit-eu/alfresco-hotfix-ALF-22094 any version

Stack Trace

de-issue-stacktrace-scheduler-beans.txt

Your Environment

  • Alfresco version used: 5.0, 5.1, 5.2, 6.0, 6.1
  • DE version affected: 2.0.3 and older
@todorinskiz todorinskiz changed the title UnsatisfiedDependencyException caused by NoUniqueBeanDefinitionException Multiple candidates for a Quartz' SchedulerFactoryBean May 14, 2020
@todorinskiz todorinskiz self-assigned this May 14, 2020
@todorinskiz todorinskiz linked a pull request May 14, 2020 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant