5 Replies Latest reply on Nov 11, 2012 11:54 PM by Ifta Khirul

    Quartz Scheduler in Jboss AS 7

    Ifta Khirul Newbie



      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 -





      public class SchedulerBean {




        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") 






                              sched.scheduleJob(testjob, trigger);






          catch (Throwable t) {

            // log exception







      And below is the  TestJob Class


      public class TestJob implements Job {


                  public void execute(JobExecutionContext context) throws JobExecutionException {

                    System.out.println("Quartz test job executed!");





      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 ?



        • 1. Re: Quartz Scheduler in Jboss AS 7
          Wolf-Dieter Fink Master

          As you are using EJB3.1 I would prefere a simple EJB Stateless or Singleton and add a @Schedule annotation. This will do the work compatilbe.

          • 2. Re: Quartz Scheduler in Jboss AS 7
            Ifta Khirul Newbie

            Ok. thanks for your reply.


            But if I still use quartz in Jboss AS 7 then how can I remove this error ?

            I think this error occured due to the changed class loading starategy in Jboss AS 7.

            I have created the module with quartz jar file  and set the dependency in Menifest.MF file but still no result.

            • 3. Re: Quartz Scheduler in Jboss AS 7
              Stephen Coy Master

              Using quartz in an EJB container has always been a bit evil because it creates threads, and you're not supposed to do that from an EJB.


              That said, it looks like the quartz-jboss implementation is only compatible with older versions of JBoss AS.


              It will be easier to use @Schedule as suggested above.

              • 4. Re: Quartz Scheduler in Jboss AS 7
                Ifta Khirul Newbie



                Thank you guys for your feedback and suggestion.

                I will try to use @Schedule as you suggested. But I have succedded to work with quartz scheduler in my project.


                Below is the detail explanation -


                I have changed the MENIFEST.MF file of my EJB project in the following way -


                Manifest-Version: 1.0


                Dependencies: org.slf4j,org.quartz



                I have also added the quartz jar file in jboss Module.

                In the module.xml file of the quartz module I have added the dependency of slf4j in the following way -


                <module xmlns="urn:jboss:module:1.1" name="org.quartz">


                        <resource-root path="quartz-all-2.1.6.jar"/>



                        <module name="org.slf4j"/>




                Thats all. And now my shcedule is running properly.

                • 5. Re: Quartz Scheduler in Jboss AS 7
                  Ifta Khirul Newbie

                  Another way is to make it workable is to place the the jar files (quartz-all-2.1.6.jar,slf4j-api-1.6.1.jar) in the lib folder of EarContent.

                  Then no need to place the dependencies in the MENIFEST.MF file.