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

SchedulerAccessor 'globalJobListeners' and 'globalTriggerListeners' not working with 2.0.x and 2.1.x [SPR-11362] #15988

Closed
spring-projects-issues opened this issue Jan 27, 2014 · 8 comments
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 27, 2014

Hatanaka, Akihiro opened SPR-11362 and commented

With Quartz 2.0, SchedulerFactoryBean throws NoSuchMethodException.

My scheduler config in appliction.xml is below.

<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="globalJobListeners">
<list>
<ref bean="qbpmContextJobListener" />
</list>
</property>
...
</bean>

There is a bug in SchedulerAccessor#registerListeners().

Quartz 2.1, 2.2 has org.quartz.core.ListenerManagerImpl.addJobListener(JobListener).
However, Quartz 2.0 does not have.

So this line throws NoSuchMethodException.

Method addJobListener = target.getClass().getMethod((quartz2 ? "addJobListener" : "addGlobalJobListener"), JobListener.class);


Affects: 3.2 GA, 3.2.6

Issue Links:

Referenced from: commits fe4b57c, c719c70

Backported to: 3.2.7

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Such Quartz API issues are a key factor why we will upgrade to Quartz 2.1+ as of Spring Framework 4.1...

That said, for 4.0.1 and 3.2.7, we should try our best to be compatible with Quartz 2.0.x as well still.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Actually the method was introduced with Quartz 2.2. This use case is failing with both 2.0 and 2.1. Investigating what we can do there.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Actually, this specific case is even worse: The addListener(JobListener) method has been introduced as of Quartz 2.2. On 2.0 and 2.1, only the variant with additional Matcher arguments exists... So we'll have to reflectively detect that, specifically for Quartz 2.x, and pass in an empty List there to enforce the global matcher. There is nothing wrong with always using that method on Quartz 2.x, it seems, so at least we don't have to differentiate between Quartz 2.0, 2.1 and 2.2 there.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed :-) Seems we have to detect the addJobListener(JobListener, List) variant and pass in an empty List there... So not just use a different method name in quartz2 mode, but also use a different signature.

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Already done, locally :) And quartz manipulates the list behind my back so it better has to be mutable!

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

The global trigger listeners were also affected by this issue (same root).

Pull request available: #452

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Applied with some minor polishing, for release in 4.0.1 as well as 3.2.7.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

After diving deeper into the Quartz 2.1.x line, it turns out that those addXListener variants without a matcher argument were actually introduced in Quartz 2.1.4. We'll rely on that in Spring Framework 4.1 then, since Quartz 2.1.4 will be 2.5 years old already when we go 4.1 GA.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants