My requirement is to start the jobs during the weblogic server startup using the spring scheduler (ThreadpoolScheduler
). Here is what i have done.
Created the Scheduler in app-context.xml-
task:scheduler id="scheduler" pool-size="10"
Created a method in a class that gets the Scheduler from the application context.xml during the @PostConstruct
@DependsOn("scheduler")
@PostConstruct
public void bootstrapJobs(){
ScheduleTask1 task = (ScheduleTask1) instanceOf(Class.forName(jobInfo.getTaskClass()));
task.setInstance(jobInfo.getJobName());
CronTrigger trigger=new CronTrigger(jobInfo.getJobFrequency());
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler)
ApplicationContextProvider.getApplicationContext().getBean("scheduler");
scheduler.schedule(task, trigger);
}
This is scheduling jobs perfectly fine on my local weblogic server, but on production it gives me the
below exception at the line... (ThreadPoolTaskScheduler
)
ApplicationContextProvider.getApplicationContext().getBean("scheduler");
scheduler.schedule(task, trigger).
Any idea on how to resolve this issue?
java.lang.NullPointerException
at SchedulerService.createJob(SchedulerService.java:67) [_wl_cls_gen.jar:?]
at SchedulerService.createBootstrapJob(SchedulerService.java:121) [_wl_cls_gen.jar:?]
at SchedulerService.bootstrapJobs(SchedulerService.java:91) [_wl_cls_gen.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_15]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_15]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_15]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_15]