0 Replies Latest reply on Nov 26, 2010 6:57 AM by Andriy Lytvynskyy

    Configuring Quartz in External properties(EJBs are not injected)

    Andriy Lytvynskyy Newbie

      Hi

       

      I'm using EJB 3.0, and I'm using Quartz, I removed all the annotations for my MDB which implements Job interface because I want to configure Quartz (cron scheduling) out of my application:

      I have quartz.properties which are in my classpath:

      #===============================================================

      # Configure Main Scheduler Properties

      #===============================================================

      org.quartz.scheduler.instanceName = QuartzScheduler
      org.quartz.scheduler.instanceId = AUTO

      #===============================================================

      # Configure ThreadPool
      #===============================================================

      org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
      org.quartz.threadPool.threadCount = 5
      org.quartz.threadPool.threadPriority = 5

      #===============================================================

      # Configure JobStore

      #===============================================================

      org.quartz.jobStore.misfireThreshold = 60000
      org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
      org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.JobInitializationPlugin
      org.quartz.plugin.jobInitializer.fileName = dpp-quartz-job.xml
      org.quartz.plugin.jobInitializer.overWriteExistingJobs = false
      org.quartz.plugin.jobInitializer.failOnFileNotFound = true

       

      I've got also dpp-quartz-job.xml which descibes my job and is placed to 'conf' folder in JBoss:

      <?xml version="1.0" encoding="UTF-8"?>

      <quartz xmlns="http://www.opensymphony.com/quartz/JobSchedulingData"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      overwrite-existing-jobs="true">
          <job>
              <job-detail>
                  <name>MyTask</name>
                  <group></group>
                  <description></description>
                  <job-class>
                      com.task.QuartzTask
                  </job-class>
                  <job-data-map allows-transient-data="false">
                      <entry>
                          <key></key>
                          <value></value>
                      </entry>
                  </job-data-map>
              </job-detail>
              <trigger>
                  <cron>
                      <name>JobTrigger</name>
                      <group>trigger-group</group>
                      <job-name>Task Parse</job-name>
                      <job-group></job-group>     

                      <!-- Daily Every day at 18:15 PM -->

                      <cron-expression> 0 15 18 * * ?</cron-expression>
                  </cron>
              </trigger>
          </job>
      </quartz>

       

      Job starts correctly, but my class QuartzTask uses some @EJB annotations, and when my job starts those annotations do not inject EJB classes,  I receive only NULL values:

      @RunAs("Administrator")
      public class QuartzTask implements Job {

          @EJB

          ManagerService manager; // is null

       

      If I use annotated configuration

      (@MessageDriven(activationConfig =
      {@ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0 15 18 ? * *")}))  - everything works OK. What can be the reason of why those beans are not injected correctly when configuring Quartz via properties? Something with classloading?