I need help in retrieving the data from database using Quartz. I am reading the hibernate properties from config.xml in the main class and using those properties I tried to retrieve the data from my job class (Quartz Process.java) which is getting Null Pointer Exception.
Please help me in resolving the issue. Thanks and advance
This is my main class:
@Component("TestProgram")
public class TestProgram
{
static ClassPathXmlApplicationContext applicationContext=null;
public void testMethod() throws SchedulerException
{
JobDetail job = new JobDetail();
job.setName("Retriving The Master Details");
job.setJobClass(QuartzProcess.class);
SimpleTrigger trigger = new SimpleTrigger();
trigger.setName("Trigger For Retriving The Master Details");
trigger.setStartTime(new Date(System.currentTimeMillis() + 1000));
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
trigger.setRepeatInterval(5000);
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
}
public static void main(String[] args) throws Exception
{
String conf[] = {"Config.xml"};
applicationContext= new ClassPathXmlApplicationContext(conf);
TestProgram unittest=applicationContext.getBean(TestProgram.class);
unittest.testMethod();
}
}
Quartz Process.java
@Component("QuartzProcess")
public class QuartzProcess implements Job
{
@Autowired
private MasterService MasterService;
@Override
public void execute(JobExecutionContext jec) throws JobExecutionException
{
try
{
List<MasterVO> MasterVO=MasterService.findAll();
System.out.println("MasterVO..."+MasterVO);
for(int index=0;index<MasterVO.size();index++)
System.out.println(MasterVO.get(index));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}