5 Replies Latest reply on Jan 30, 2010 4:01 PM by allforjava.allforjava.aol.in

    NPE: quartzTriggerHandle.cancel()

    allforjava.allforjava.aol.in
      Hi,

      I coded quartz example with the help of seam.2.2.0 quartz example. I'm newbie for the scheduler's part & @Asynchronous.

      The @Asynchronous method is processed as expected with defined intervals.

      Now I need to stop/cancel them specifically. With returned QuartzTriggerHandle the pause(), cancel() & resume() invocation throws NPE-NullPointerException.

      How to proceed? Am I using in worng way? Kindly guide.

        • 1. Re: NPE: quartzTriggerHandle.cancel()
          allforjava.allforjava.aol.in

          Code snippet:


          @Name("timer")
          public class Timer{
          
              @In Processor processor;
              
              private QuartzTriggerHandle handle;
              
              public void start(){
                   processSchedule();
              }
              
              public void stop() throws SchedulerException{
                   handle.cancel();
              }
              
              public void pause() throws SchedulerException{
                   handle.pause();
              }
              
              public void resume() throws SchedulerException{
                   handle.resume();
              }
              
              public void processSchedule(){
                   Date start = new Date();
                  Calendar end = Calendar.getInstance();
                       end.set(2010, Calendar.MAY, 10);
                   handle = processor.schedule(start,1000*10L,end.getTime());
                   display(handle);
              }
              
              private void display(QuartzTriggerHandle triggerHandle){
                   System.out.println("Handle: "+triggerHandle);
                   Scheduler scheduler = QuartzDispatcher.instance().getScheduler();
                   try {
                         System.out.println("Groups: "+scheduler.getJobGroupNames());
                         System.out.println("Defualted Jobs: "+scheduler.getJobNames(Scheduler.DEFAULT_GROUP));
               } catch (SchedulerException e) {
                    e.printStackTrace();
               }
              }
          }
          

          • 2. Re: NPE: quartzTriggerHandle.cancel()
            kapitanpetko

            Stack trace?

            • 3. Re: NPE: quartzTriggerHandle.cancel()
              allforjava.allforjava.aol.in

              Thank you for quick response. Stack trace for stop():


              19:24:46,452 INFO  [STDOUT] Handle: org.jboss.seam.async.QuartzTriggerHandle@5a9737
              19:24:46,452 INFO  [STDOUT] Groups: [Ljava.lang.String;@17da237
              19:24:46,452 INFO  [STDOUT] Defualted Jobs: [Ljava.lang.String;@124d0d3
              19:24:46,546 INFO  [STDOUT] Schedule Triggerred: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
              19:25:07,568 SEVERE [application] java.lang.NullPointerException
              javax.faces.el.EvaluationException: java.lang.NullPointerException
                   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
                   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                   .
                   .
                   .
              Caused by: java.lang.NullPointerException
                   at adr.scheduler.workout.Timer.stop(Timer.java:50)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                   .
                   .
                   .
              Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
                   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
                   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                   ... 52 more
              Caused by: java.lang.NullPointerException
                   at adr.scheduler.workout.Timer.stop(Timer.java:50)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   .
                   .
              19:25:07,599 SEVERE [lifecycle] JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: /views/timer.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1427c43]
              19:25:16,448 INFO  [STDOUT] Schedule Triggerred: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
                   
              

              • 4. Re: NPE: quartzTriggerHandle.cancel()
                kapitanpetko

                This has nothing to do with Quartz, if you want to save state for longer than a method call you need to use conversation or session scope. Your Timer component is not event-scoped (default), that is why it loses state after the first call.


                HTH

                • 5. Re: NPE: quartzTriggerHandle.cancel()
                  allforjava.allforjava.aol.in

                  Thank you Nikolay! It works.


                  I over-looked the post http://seamframework.org/Community/QuartzTriggerHandleIsNull#comment100039


                  Any usage examples for QuatzDispatcher scheduleTimedEvent(), etc.