Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [JBoss Seam] - em is always null in my quartz
 scheduler, plz help.

scott.stark@jboss.org

2007-08-07


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071468#4071468

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071468
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.