Using CDI in Quartz Jobs

I would like to know if it is possible to use CDI beans in Quartz jobs in a portable way?

I have already tried to write my own JobFactory and so on, but the problem is, that the BeanManager is not available through JNDI, because the job runs in a non managed thread. My application server is Websphere and I already read that it is against the EE6 spec to make the name "java:" available to non managed threads.

There are two solutions now I think:

<ol> <li>Let Websphere create the worker threads(Don't know how to do that, any help would be nice)</li> <li>Implement an EJB and call the method through the EJBJobInvoker</li> </ol>

I know that, when I use the CDI solution, then I am not able to let the worker threads run in a different JVM, correct me if I am wrong. To stay scaleable I should implement an EJB for that? What do you think, have you ever had that problem? I would also appreciate different solutions or even suggestions on different scheduler libraries!


Look at DeltaSpike scheduler module.

You can find last version on Maven Central Repository.


You can take a look at DeltaSpike and use its BeanManagerProvider, or you can create a PortableExtension and cache a reference to the BeanManager in the extension and use that. There shouldn't be a problem doing things that way.


There seem to be a quick'n'dirty way to have CDI in local Quartz environment: set your own subclass of PropertySettingJobFactory in your scheduler, which has its own injected instance of BeanManager and does the following to every created job:

Job job = super.newJob(bundle, Scheduler); Class<? extends Job> clazz = job.getClass(); if (beanManager != null) { CreationalContext<Job> ctx = beanManager .createCreationalContext(null); @SuppressWarnings("unchecked") AnnotatedType<Job> type = (AnnotatedType<Job>) beanManager .createAnnotatedType(clazz); InjectionTarget<Job> it = beanManager.createInjectionTarget(type); it.inject(job, ctx); }

Then @Injects will be filled in your Jobs on creation.


Have you look at CDIQI its a CDI Quartz implementation that you may be able to model your own after?


Or is your problem that you absolutely need to create your own threads? CDIQI has an asynchronous execution of jobs but it sounds like you want to run yours remotely on another JVM?


  • link library to all targets in cmake project
  • Why == is different for Integer and String?
  • How to remove trailing space from marquee?
  • C++ #include Loop
  • Selenium c#: WaitForCondition (how to find when ajax page is fully loaded)
  • Is MVC2 ASP.Net URLDecoding automatically?
  • Is there an API (SOAP, JSON, XML-RPC, REST, anything) to Google Code Issues?
  • How to distribute an event to all nodes in a (Wildfly) cluster?
  • Pointer vs Reference difference when passing Eigen objects as arguments
  • Multiple flexboxes with margin-right, except the last one in the row? Without JS?
  • Search function not doing anything
  • Python function to read variable length blocks of data from file while open
  • Zend Framework bassed projects
  • Find VMID for running instance
  • Embedded Glassfish JPA Datasource connection fail
  • IE6 changes DOCTYPE to a bad one
  • ZipList with Scalaz
  • “mvn clean generate-source” could not resolve dependencies
  • What is the correct way to synchronize a shared, static object in Java?
  • Web.config system.webserver errors
  • How do I superscript characters in a UIButton?
  • Android full screen on only one activity?
  • What is Eclipse's Declaration View used for?
  • C# - Serializing and deserializing static member
  • Bug in WPF DataGrid
  • Excel - Autoshape get it's name from cell (value)
  • Incrementing object id automatically JS constructor (static method and variable)
  • Check if a string to interpolate provides expected placeholders
  • Where to put my custom functions in Wordpress?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • 0x202A in filename: Why?
  • SVN: Merging two branches together
  • RestKit - RKRequestDelegate does not exist
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Traverse Array and Display in markup
  • WPF Applying a trigger on binding failure
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • File not found error Google Drive API
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]