1 Reply Latest reply on Jun 8, 2011 9:24 AM by Martial Maillot

    Seam 2.2.1 + Quartz : Error NullPointerException

    Martial Maillot Newbie

      Hi !


      I want to use Quartz to schedule a job. To begin, i try a example, i want to write a text in the log file every minutes.


      Seam.quartz


      #==============================================================
      # Configure Main Scheduler Properties
      #==============================================================
      
      org.quartz.scheduler.instanceName Sched1
      org.quartz.scheduler.instanceId AUTO
      org.quartz.scheduler.rmi.export false
      org.quartz.scheduler.rmi.proxy false
      
      #==============================================================
      # Configure ThreadPool
      #==============================================================
      
      org.quartz.threadPool.class org.quartz.simpl.SimpleThreadPool
      org.quartz.threadPool.threadCount 1
      
      #==============================================================
      # Configure JobStore
      #==============================================================
      
      org.quartz.jobStore.misfireThreshold 60000
      org.quartz.jobStore.class org.quartz.simpl.RAMJobStore



      Scheduler.java :



      package com.adecco.esb.supervision.scheduler;
      
      import java.util.Date;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.AutoCreate;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Transactional;
      import org.jboss.seam.annotations.async.Asynchronous;
      import org.jboss.seam.annotations.async.Expiration;
      import org.jboss.seam.annotations.async.IntervalCron;
      import org.jboss.seam.async.QuartzTriggerHandle;
      import org.jboss.seam.log.Log;
      
      /**
       * Description :
       * 
       * @author Martial Maillot SendMail.java - 8 juin 2011 09:58:08
       */
      @Name("scheduler")
      @AutoCreate
      @Scope(ScopeType.APPLICATION)
      public class Scheduler {
      
           @Logger
           private Log log;
      
           @Asynchronous
           @Transactional
           public QuartzTriggerHandle doJob(@Expiration Date when,
                     @IntervalCron String interval) {
      
                System.out.println("I am a Quartz job.");
      
                return null;
      
           }
      
      }



      MyController.java



      package com.adecco.esb.supervision.scheduler.controller;
      
      import static org.jboss.seam.ScopeType.APPLICATION;
      
      import java.io.Serializable;
      import java.util.Date;
      
      import org.jboss.seam.annotations.AutoCreate;
      import org.jboss.seam.annotations.Create;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Startup;
      import org.jboss.seam.async.QuartzTriggerHandle;
      import org.jboss.seam.log.Log;
      
      import com.adecco.esb.supervision.scheduler.Scheduler;
      
      /**
       * Description :
       * 
       * @author Martial Maillot SendMailController.java - 8 juin 2011 10:01:52
       */
      @Name("controller")
      @Scope(APPLICATION)
      @AutoCreate
      @Startup
      public class MyController implements Serializable {
      
           private static final long serialVersionUID = 7609983147081676186L;
      
           @In
           Scheduler processor;
      
           @Logger
           Log log;
      
           private QuartzTriggerHandle quartzTriggerHandleDoJob;
      
           @Create
           public void scheduleTimer() {
                quartzTriggerHandleDoJob = processor.doJob(new Date(), "0 0/1 * * * ?");
           }
      
      }



      When i start my Tomcat server, i've this error :




      org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: controller
           at org.jboss.seam.Component.newInstance(Component.java:2170)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:143)
           at org.jboss.seam.init.Initialization.init(Initialization.java:747)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
           at org.apache.catalina.core.StandardService.start(StandardService.java:519)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
      Caused by: java.lang.NullPointerException
           at com.adecco.esb.supervision.scheduler.controller.MyController.scheduleTimer(MyController.java:43)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at com.adecco.esb.supervision.scheduler.controller.MyController$$javassistseam3.scheduleTimer(MyController$$javassistseam3.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2198)
           at org.jboss.seam.Component.newInstance(Component.java:2158)
           ... 20 more


      Please, help me, i don't understand why i've this error... thanks !