My code contains the basic exmaple of quartz schedular.. In normal java application its running but when Im converting it as a bundle and deploying it in karaf its not working.
@Component
@Service
public class testImpl implements testI {
@Override
public void test() {
System.out.println("testImpl started");
try {
JobDetail job = JobBuilder.newJob(TestJob.class)
.withIdentity("testJob")
.build();
System.out.println("job \n");
Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(
SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(5)
.repeatForever())
.build();
System.out.println("trigger \n ");
//THIS PARTICULAR LINE ONWARDS THE CODE IS NOT EXCUTING IM NOT GETTING SYSOUT AFTER THIS LINE.
SchedulerFactory schFactory = new StdSchedulerFactory();
System.out.println("scheduler \n");
Scheduler sch = schFactory.getScheduler();
sch.start();
sch.scheduleJob(job, trigger);
} catch (Exception e) {
e.printStackTrace();
}
}
Schedular is throwing exceptions like
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.quartz.impl.StdSchedulerFactory.<init>(StdSchedulerFactory.java:298)
at com.ericsson.testImpl.testImpl.test(testImpl.java:77)
at com.ericsson.testConsumer.testConsumer.bindTestI(testConsumer.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
but as far as I know Karaf has a inbuilt support for slf4j. No need of explicitly adding slf4j bundle.
I found out root cause of the error. In Quartz jar pom.xml the slf4j dependency version was 1.6.1 and my Karaf-2.3.3 inbuilt slf4j dependency is 1.6.6. Changing the quartz pom with the correct version for dependencies helps.