5 Replies Latest reply on Dec 13, 2007 9:53 PM by genman

    jboss sheduler issue

    mcjeevi

      hi

      what are steps need to configure to implement Jboss scheduler in jboss4.0..2



      Regards

        • 1. Re: jboss sheduler issue
          popoctavian

          A simple way to create a sceduler is to implement Schedulable interface, you have to implement public void perform(Date data, long l) method.
          This interface is found in sceduler-plugin.jar, for jboss 4.0.5.

          A sample cod is:

          public class MyScheduler implements Schedulable
          {
           public void perform(Date data, long l)
           {
           execute();
           }
          }
          

          and the deployment descriptor from jboss-service is:

          <server>
           <mbean code="org.jboss.varia.scheduler.Scheduler"
           name="acme:service=Scheduler">
           <attribute name="StartAtStartup">true</attribute>
           <attribute name="SchedulableClass">MyScheduler</attribute>
           <attribute name="InitialStartDate">NOW</attribute>
           <attribute name="SchedulePeriod">60000</attribute>
           <attribute name="InitialRepetitions">-1</attribute>
           </mbean>
          </server>


          I hope it helps you.



          • 2. Re: jboss sheduler issue
            cpetru

            And whart next?
            Where & how do I include the xml file in the ear file ?

            I'm trying to just print a text in the consile. So, execute() is
            System.out.print("Listener called");

            I included META-INF/scheduler-service.xml in the jar package.

            I expect to see this message in the eclipse console, just after .ear deploy.

            Am I correct ? What do I do wrong ?

            Thank you very much.

            • 3. Re: jboss sheduler issue
              cpetru

              OK. I found my problem:
              2 files were to be added in META-INF
              - scheduler-service.xml having the tag

              <mbean code="org.jboss.varia.scheduler.Scheduler" ...>

              described above

              - jboss-app.xml with
              <jboss-app>
               <module>
               <service>META-INF/scheduler-service.xml</service>
               </module>
              </jboss-app>


              And these 2 files must be added in eclipse packaging configuration page in the Project.ear node with the prefix META-INF

              Finally works for me: a message appears at 3 secconds in the console window.

              • 4. Re: jboss sheduler issue
                rrupel

                I did that with an existing Stateless bean of my application and it worked well untill I injected another bean with the @EJB annotation

                then it couldnt deploy... NullPointerExeption...

                i searched a lot... and tryed with SchedulableMBean instead... but I cant get things working...

                it worked like this guy said... but how to make it work if the SchedulableClass is a bean... or have to import a bean?

                regards

                • 5. Re: jboss sheduler issue
                  genman

                  Is it because your scheduler is deployed before the EJB is deployed? You may want to add a "depends" to your scheduler so it appears after jboss initializes it. Also, always post your stack traces.