Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-1778

NPE calling QuartzJobScheduler.fireJob if the job is a CronJob

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.8
    • 2.1.9
    • Blocks: Cron
    • None
    • Normal
    • Patch available

    Description

      calling scheduler.fireJob (for example from flow) results in an NPE if the job is a CronJob. This is because the JobExecutionContext is created without a Trigger in the TriggerFiredBundle. The constructor for JobExecutionContext requires that there be a trigger in the firebundle when it calls:

              this.jobDataMap.putAll(trigger.getJobDataMap());

      on line 139.

      Here is some sample flowscript that fires a CronJob.

          var scheduler = cocoon.getComponent(Packages.org.apache.cocoon.components.cron.JobScheduler.ROLE);
          try {
      scheduler.fireJob("someJob");
          } finally {
           cocoon.releaseComponent(scheduler);
          }

      Here is a patch (license granted to ASF):

      Index: C:/opt/eclipse-rc/eclipse/workspace/cocoon-svn/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java
      ===================================================================
      --- C:/opt/eclipse-rc/eclipse/workspace/cocoon-svn/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java (revision 376375)
      +++ C:/opt/eclipse-rc/eclipse/workspace/cocoon-svn/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java (working copy)
      @@ -704,10 +704,12 @@
       
                       final JobDetail detail = createJobDetail(name, jobDataMap);
       
      - TriggerFiredBundle trigger = new TriggerFiredBundle(detail, null, null, false, null, null, null, null);
      + final Trigger trigger = new SimpleTrigger(name, DEFAULT_QUARTZ_JOB_GROUP);
       
      + TriggerFiredBundle fireBundle = new TriggerFiredBundle(detail, trigger, null, false, null, null, null, null);
      +
                       final Job executor = createJobExecutor();
      - final JobExecutionContext context = new JobExecutionContext(this.scheduler, trigger, executor);
      + final JobExecutionContext context = new JobExecutionContext(this.scheduler, fireBundle, executor);
       
                       this.executor.execute(new Runnable() {
                               public void run() {

      Attachments

        Activity

          People

            antonio Antonio Gallardo Rivera
            eric.meyer Eric Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: