question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DI is not working properly on Job instances when scheduling quartz jobs programmatically

See original GitHub issue

Describe the bug When using job classes with programmatic job/triggers in quartz, fields annotated with @Inject gets injected, but with instances that have fields which have not been injected.

I discovered this problem when using a @ConfigProperty field which had different values at different times. After elaborating, this also applies to @Inject ed fields.

Expected behavior Fields on injected beens in Job classes should also have their fields injected.

Actual behavior Fields injected with @Inject and @ConfigProperty are null (or primitive default) when using a bean injected into a Job class.

To Reproduce https://github.com/lbroman/quarkus-config-bug

Run with

mvn test

Result will put out some log and you will find

2021-01-19 21:40:24,895 INFO  [se.lbr.qua.JobScheduler] (main) Setting is: true
2021-01-19 21:40:24,915 DEBUG [se.lbr.qua.JobScheduler] (QuarkusQuartzScheduler_Worker-1) Setting is: false

JobScheduler is application scoped and setting is injected with @ConfigProperty. The value of the field is correct during init, but incorrect when accessed from quartz via the Job instance.

Environment (please complete the following information):

  • Output of uname -a or ver: MINGW64_NT-10.0-18362 BB904078 3.0.7-338.x86_64 2019-07-03 15:16 UTC x86_64 Msys

  • Output of java -version:

  • openjdk version “15” 2020-09-15 OpenJDK Runtime Environment (build 15+36-1562) OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

  • GraalVM version (if different from Java): n/a

  • Quarkus version or git rev: tried 1.10.5.Final and 1.10.3.Final

  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
manovotncommented, Jan 20, 2021

FTR, as per @mkouba’s request (Zulip) I’ve verified this with Weld (CDI reference implementation) and I can confirm that it behaves equally.

2reactions
lbromancommented, Jan 20, 2021

Sorry for posting what was actually a support question as a bug. I would not have been able to figure this out myself. Thanks so much for the explanation!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Job Schedule Quartz - java - Stack Overflow
Is it possible to add/remove/modify Job which is scheduled in Quartz + Spring Boot dynamically (during run ...
Read more >
Guide to Quartz with Spring Boot - Job Scheduling and ...
Learn how to build your own Quartz Management Console with Java and Spring Boot - perform job scheduling and automation with one of...
Read more >
Dynamic Job Scheduling with Quartz and Spring - Julius Krah
We will dynamically create jobs that sends emails to a predefined group of people on a user defined schedule using Spring Boot. Project ......
Read more >
Quartz Scheduler Developer Guide
Job - an interface to be implemented by components that you want the Scheduler to execute. JobDetail - used to define instances of...
Read more >
Job Scheduling - Spark 3.3.1 Documentation - Apache Spark
If the jobs at the head of the queue don't need to use the whole cluster, later jobs can start to run right...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found