Quartz Scheduler in Jboss AS 7
ifti24 Nov 9, 2012 3:19 AMHi,
I'm trying to implement quartz scheduler in on of my EJB application with Jboss AS 7.
I have included quartz-jboss-2.1.6.jar and quartz-all-2.1.6 jar in my EJB application.
I have implemented my SchedulerBean in the following way -
{code}
@Startup
@Singleton
public class SchedulerBean {
@PostConstruct
void init() {
try {
Scheduler sched = new StdSchedulerFactory().getScheduler();
// schedule jobs here
JobDetail testjob = JobBuilder.newJob(TestJob.class).withIdentity("testjob", "testgroup").build();
SimpleTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity("testtrigger", "testgroup")
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(10)
.repeatForever())
.build();
sched.scheduleJob(testjob, trigger);
sched.start();
}
catch (Throwable t) {
// log exception
}
}
}
{code}
And below is the TestJob Class
{code}
public class TestJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Quartz test job executed!");
}
}
{code}
Everything is ok in the compile time. But when I start my application (Then Enterprise application) I got the following Error -
----------------
Caused by: java.lang.NoClassDefFoundError: org/quartz/ScheduleBuilder
at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.7.0_09]
at java.lang.Class.privateGetDeclaredFields(Class.java:2308) [rt.jar:1.7.0_09]
at java.lang.Class.getDeclaredFields(Class.java:1760) [rt.jar:1.7.0_09]
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 10 more
Caused by: java.lang.ClassNotFoundException: org.quartz.ScheduleBuilder from [Module "deployment.TestEnterpriseProject.ear.TestEjbProject.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 15 more
-----------------
Can anybody help me to findout a way to solve this issue please ?