views:

221

answers:

2

hi,

i am getting he following Exception while running my Quartz Schdular program.

Below is the exception Trace

Mar 26, 2010 2:54:24 PM org.quartz.core.QuartzScheduler start INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started. Exception in thread "main" java.lang.IllegalArgumentException: Job class must implement the Job interface. at org.quartz.JobDetail.setJobClass(JobDetail.java:291) at org.quartz.JobDetail.(JobDetail.java:138) at com.Quarrtz.RanchSchedule.main(RanchSchedule.java:18)

i have included Quartz-1.7.2.jar and Quartz-all-1.7.2.jar in my class path along with commom-logging 1.1.jar and jdk 6

this is an example i have copy and pasted from JAVA RANCH

http://www.javaranch.com/journal/200711/combining_spring_and_quartz.html

First example in the above page

any help pls

my code as follows

**public interface Job {

void execute (JobExecutionContext ctx);

}**

**public class RanchJob implements Job {

public void execute (JobExecutionContext ctx) throws JobExecutionException {
    System.out.println("[JOB] Welcome at JavaRanch");
}

}**

**public class RanchSchedule {

public static void main (String[] args) {       
    try {
        SchedulerFactory factory = new org.quartz.impl.StdSchedulerFactory();

        Scheduler scheduler = factory.getScheduler();
        scheduler.start();

        JobDetail jobDetail = new JobDetail("ranchJob", null, RanchJob.class);
        // Fires every 10 seconds
        Trigger ranchTrigger = TriggerUtils.makeSecondlyTrigger(10); 
        ranchTrigger.setName("ranchTrigger");

        scheduler.scheduleJob(jobDetail, ranchTrigger);
    } catch (SchedulerException ex) {
        ex.printStackTrace();
    }
}

}**

thanx in advance

Sunny Mate

A: 

Don't include both Quartz-1.7.2.jar and Quartz-all-1.7.2.jar - include one or the other, or you risk weird classloading bugs, which your problem sounds like.

skaffman
hi skaffman,thanx for u r suggestioni have tryied with one jar but getting same Exception any other suggestion pls
Sunny Mate
here is the source codepublic interface Job { void execute (JobExecutionContext ctx);}public class RanchJob implements Job { public void execute (JobExecutionContext ctx) throws JobExecutionException { System.out.println("[JOB] Welcome at JavaRanch"); }}
Sunny Mate
public class RanchSchedule { public static void main (String[] args) { try { SchedulerFactory factory = new org.quartz.impl.StdSchedulerFactory(); Scheduler scheduler = factory.getScheduler(); scheduler.start(); JobDetail jobDetail = new JobDetail("ranchJob", null, RanchJob.class); // Fires every 10 seconds Trigger ranchTrigger = TriggerUtils.makeSecondlyTrigger(10); ranchTrigger.setName("ranchTrigger"); scheduler.scheduleJob(jobDetail, ranchTrigger); } catch (SchedulerException ex) { ex.printStackTrace(); } }}
Sunny Mate
@Sunny: Please post your code as an edit to your question, don't dump it in unreadable comments.
skaffman
+1  A: 

Have you written the Job interface in your source code ?

public interface Job {
    void execute (JobExecutionContext ctx);
}

If so, you don't have to do this. Quartz has its own Job interface (in the quartz.jar). Keep only your RanchJob and RanchSchedule classes and it should work.

Antoine
thank you very much Mr Antonie
Sunny Mate