Search code examples
javaejb-3.0weblogicquartz-scheduler

Injection inside Quartz Job


I am using weblogic 11, ejb3.0

I am trying to do Ejb injection inside a class which implements Job (org.quartz.job) No success.

So i Thought to make my job class as a stateless bean. like that:

 @Stateless(mappedName = "StartSyncJob")
 @Local(
  { StartSyncJob.class })
 public class StartSyncJob implements Job  
  ...

and then tried the Ejb injection inside again but I got exception:

blogic.ejb.container.compliance.ComplianceException: Business method notify in class java.lang.Object must not be declared as final

Guess I cant annotate a class which implements Job interface.

any other Idea how can I do it?

My main target is to call stateless bean which exists in another deployment from my Job class.


Solution

  • The container can only inject things created/managed by the container.

    Quartz instantiates the job instances.

    Hence the two don't play together as one framework.

    You can create your own implementation of Quartz's JobFactory class to be in control of the instantiation of the job - and your implementation can delegate to something else, like the container.

    Also, in your job, you can look up the Stateless bean yourself and then invoke it. Quartz ships with an EjbInvokerJob that does just that (invokes a configured ejb when it executes).