• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

EJB3 stateless session beans and Quartz Issue

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here, Quartz is going to instantiate a new CronJobBean, but it will not be a managed stateless bean. So nothing will be injected in reportGenerationBean. Why don't you lookup the ReportGenerationLocal manually, via the InvocationContext ? Or you can look into Quartz's EJBInvokerJob class
 
Harshi Gunarathna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Christophe
I tried it, but still i get some new Exceptions.Can you please describe the way to apply EJBInvokerJob class with EJB or else provide me a resource to understand it properly. Because i am new to EJB as well as Quartz.

Thanks in advance,
Harshi
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you find the solution? If yes means Please post the answer

thanks
 
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Karthick saran wrote:Did you find the solution? If yes means Please post the answer

thanks

After 12 years, I doubt they're still working with it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic