1 Reply Latest reply on Dec 23, 2013 4:31 PM by itays100

    Inject Seam Component To Quartz Job

    itays100 Newbie

      Hi All,


      I've successfully integrated seam with Quartz using the interface org.quartz.Job as describe in the following link:



      I need to access the database through the Job class. In order to do so I annotate the Job class with

      seam annotations and injected a DAO object as follow:





      public class MyJob implements org.quartz.Job {    


        private MyDaoHibernateImpl myDao;



      The problem is that the myDao is null when executing the code.

      "myDao" is also the name of the component as required by seam.


      The scheduler is created exactly as described in the link above with 1 different, it is an application scope component:





      public class ScheduleController implements Serializable {


          public void scheduleTimer() {


          try {

               SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();

               Scheduler sched = schedFact.getScheduler();


               JobDetail jobDetail = new JobDetail(



      If you have any experience with injecting a seam component into a Job object please share.



        • 1. Re: Inject Seam Component To Quartz Job
          itays100 Newbie



          I would like to share my solution for this problem.

          Because there is an issue to inject seam component into Quartz job I have added the following code

          to the execute method as follow:


          public void execute(JobExecutionContext arg0) throws JobExecutionException {



                  EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");


                  MyDao myDao = (MyDao)org.jboss.seam.Component.getInstance("myDao"); 



          The MyDao is used as a Seam component and being injected to other Seam component and

          the only time I used  dataFeedDao.setEntityManager(entityManager) is in Quartz job.


          Hope this help someone.