hi,
I am trying to use Quartz job scheduler with EJB3 stateless session beans. I created one bean by implementing the org.quartz.job and the other with the trigger which provides the schedule for the job.My requirement is to invoke a method per minute.Inside the execute method i am calling a method of another stateless session bean (which implements its' remote interface).Once the program run it throws "NullPointerException".I tried to fix it but i couldn't fix it.
@Stateless
public class CronScheduleBean implements CronScheduleRemote {
public CronScheduleBean() {}
public
String autoSchedule(String a)throws Exception {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
JobDetail jd = new JobDetail("job1", "group1", CronJobBean.class);
CronTrigger ct = new CronTrigger("cronTrigger", "group2", "0 0/1 * * * ?");
sched.scheduleJob(jd, ct);
sched.start();
return a;
}
--------------------------------------------------------------------
@Stateless
public class CronJobBean implements CronJobRemote,Job {
@EJB
private ReportGenerationLocal reportGenerationBean;
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("ReportGenerationBean :" + new Date());
reportGenerationBean.generateEODReport("2008-10-26"); }
--------------------------------------------------------------------
Output Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
ReportGenerationBean :Tue Nov 25 08:54:00 IST 2008
Job group1.job1 threw an unhandled Exception:
java.lang.NullPointerException
at com.mjoy.cp.reporting.CronJobBean.execute(CronJobBean.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Job (group1.job1 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.lang.NullPointerException
Can anyone please help me to fix this issue.
Thanks in advance,
Harshi.