4 Replies Latest reply on Aug 11, 2007 10:10 PM by Gus Gu

    em is always null in my quartz scheduler, plz help.

    Stateless Bean Novice

      Hello,
      I implemented my opensymphony quartz in Seam 1.6.1 GA app using JBoss 4.0.5. For some reasons I don't want to use Seam asynchronous.
      My problem is I always get em injected as null, why?

      here is my copomenents.xml

      <core:managed-persistence-context name="em"
      auto-create="true" persistence-unit-jndi-name="java:/sguEntityManagerFactory" />
      


      Scheduler listener

      public class StartupListener implements ServletContextListener {
      
       public void contextInitialized(ServletContextEvent contextEvent) {
       SchedulerSystem obiektKlasyW = new SchedulerSystem();
      
       Thread watekPrzeliczniaCennika = new Thread(obiektKlasyW);
      
       watekPrzeliczniaCennika.start();
      
       }
      
       public void contextDestroyed(ServletContextEvent arg0) {}
      }
      


      public class SchedulerSystem implements Runnable {
      
       public void run() {
       SchedulerFactory schedFact = new rg.quartz.impl.StdSchedulerFactory();
      
       Scheduler sched = null;
       try {
       sched = schedFact.getScheduler();
       } catch (SchedulerException e) {
       e.printStackTrace();
       }
      
       try {
       sched.start();
       } catch (SchedulerException e) {
       e.printStackTrace();
       }
      
       //JobDetail jobDetail = new JobDetail("CennikJob", "groupCeniki", JobPrzeliczanieCennika.class);
       JobDetail jobDetail = new JobDetail("CennikJob", "groupCeniki", SchedulerJobs.class);
      
       Trigger trigger = TriggerUtils.makeSecondlyTrigger(2);
       trigger.setName("CennikiTrigger");
       trigger.setGroup("groupCeniki");
       trigger.setStartTime(new Date());
      
      
       try {
       sched.scheduleJob(jobDetail, trigger);
       } catch (SchedulerException e) {
       e.printStackTrace();
       }
      
       }//run()
      
      }
      


      and my job

      public class SchedulerJobs implements Job {
       public SchedulerJobs() {}
      
       @In(create=true)
       protected EntityManager em;
      
       public void execute(JobExecutionContext kontekst) {
       Date date = new Date();
       //HERE i GET NULL my EM
      
       }
      }
      


      Can anyone help me, hot to create/inject well my em?