7 Replies Latest reply on Feb 2, 2011 9:48 AM by jbosslars

    JBoss AS6 and Quartz 1.8.4 Not Finding Properties

    jbosslars

      We're trying to upgrade from JBoss 5 to JBoss 6, and step up to Quartz 1.8.4 in the process. I have been completely unsuccessful in getting JBoss 6 to load my quartz.properties file and am looking for advice from someone who has succeeded at this, or someone who knows how this is supposed to happen.

       

      The files

      my-quartz.properties (scaled back for testing), which contains:

      org.quartz.scheduler.instanceName = QuartzScheduler

      org.quartz.scheduler.instanceId = AUTO

      org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool

      org.quartz.threadPool.threadCount = 5

      org.quartz.threadPool.threadPriority = 5

      org.quartz.jobStore.misfireThreshold = 60000

      org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore

       

      properties-service.xml, which contains:

          <attribute name="Properties">

            org.quartz.properties=${jboss.server.config.url}my-quartz.properties

          </attribute>

       

      Actions Attempted

      I've tried placing the my-quartz.properties file in %JBOSS_HOME%/bin, %JBOSS_HOME%/server/default/conf, and %JBOSS_HOME%/server/default/deploy - with a failed load defaulting back to the quartz.properties in the quartz jar (see Results, Part 2).

       

      I ran across a thread yesterday about updating %JBOSS_HOME%/server/default/deply/properties-service.xml, which I'm including here.

       

      The Results, Part 1

      When updating properties-service.xml and restarting JBoss, it throws the following error:

      13:16:51,614 INFO  [[/QuartzTest]] QuartzInitializer: Quartz Scheduler failed to initialize: org.quartz.SchedulerException: Properties file: 'file:/Users/me/jboss-6.0.0.Final/server/default/conf/my-quartz.properties' could not be found.

       

      Yet if I run this from a command prompt, it displays the file contents just fine:

      less /Users/me/jboss-6.0.0.Final/server/default/conf/my-quartz.properties

      Note that is exactly the file JBoss says it cannot find.

       

      The file exists, it has the proper permissions, yet JBoss cannot find it. To confirm it's not a permissions issue I ran JBoss as root and received the same error.

       

      The Results, Part 2

      Before finding the properties-service.xml solution, I tried locating my-quartz.properties in the classpath (%JBOSS_HOME%/bin, %JBOSS_HOME%/server/default/conf, and %JBOSS_HOME%/server/default/deploy). When started, JBoss throws the following info message:

      13:32:55,896 INFO  [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'

       

      Again, it obviously cannot locate the file.

       

      Prologue

      I'm completely stumped. Nothing I have tried has been able to be loaded by JBoss. Anyone have any ideas?

       

      Thanks,

      Larry

       

       

       


        • 1. JBoss AS6 and Quartz 1.8.4 Not Finding Properties
          nickarls

          Can it find it if you place it in the classpath root inside your application?

          • 2. JBoss AS6 and Quartz 1.8.4 Not Finding Properties
            jbosslars

            I've tried placing the file in the WEB-INF directory of the application, and the INFO message still says "initialized from default resource".

             

            And besides - that won't work if you have multiple applications on a server that use Quartz. How could they each have the quartz config? Correct?

            • 3. Re: JBoss AS6 and Quartz 1.8.4 Not Finding Properties
              jbosslars

              I have just successfully loaded the quartz.properties when it's placed inside my WEB-INF directory by adding the following (in bold) to web.xml:

               

                <servlet>

                  <servlet-name>QuartzInitializer</servlet-name>

                  <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>  

                  <init-param>

                    <param-name>shutdown-on-unload</param-name>

                    <param-value>true</param-value>

                  </init-param>

                  <init-param

                    <param-name>start-scheduler-on-load</param-name> 

                    <param-value>true</param-value> 

                  </init-param

                  <init-param>

                    <param-name>config-file</param-name>

                    <param-value>my-app-quartz.properties</param-value>

                  </init-param>

                  <load-on-startup>1</load-on-startup>

                </servlet>

               

               

              Confirmed with log output:

              15:22:42,253 INFO  [StdSchedulerFactory] Quartz scheduler 'QuartzScheduler' initialized from the specified file : 'my-app-quartz.properties' from the class resource path.

               

              So, this is progress. But the question remains - is this a good practice since there will be more than one application running on the JBoss server that uses Quartz? Shouldn't this be a server-wide setting? And, how do you make that happen? Under JBoss 5, we just placed it in the bin directory of the server, along with all of the <appname>-jobs.xml files; worked like a champ - and maybe we violating rules and lucky.

               

               

               

               


              • 4. Re: JBoss AS6 and Quartz 1.8.4 Not Finding Properties
                nickarls

                It does appear a bit overkill, yes. And no luck on the Quartz forums? One would think that someone over there would have run into this issue...

                • 5. Re: JBoss AS6 and Quartz 1.8.4 Not Finding Properties
                  nickarls

                  Have you tried to force-feed it something like /tmp/q.properties to see at which point the file:/ url appears?

                  • 6. Re: JBoss AS6 and Quartz 1.8.4 Not Finding Properties
                    jaikiran

                       <attribute name="Properties">

                          org.quartz.properties=${jboss.server.config.url}my-quartz.properties

                        </attribute>

                     

                    ....

                     

                    The Results, Part 1

                    When updating properties-service.xml and restarting JBoss, it throws the following error:

                    13:16:51,614 INFO  [[/QuartzTest]] QuartzInitializer: Quartz Scheduler failed to initialize: org.quartz.SchedulerException: Properties file: 'file:/Users/me/jboss-6.0.0.Final/server/default/conf/my-quartz.properties' could not be found.

                     

                    Like I suspected the Quartz StdSchedulerFactory can't handle the "file:" protocol in the file "name":

                     

                     public void initialize(String filename) throws SchedulerException {
                      ...
                      InputStream is = null;
                                 Properties props = new Properties();
                    
                                 is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
                    
                                 try {
                                     if(is != null) {
                                         is = new BufferedInputStream(is);
                                         propSrc = "the specified file : '" + filename + "' from the class resource path.";
                                     } else {
                                         is = new BufferedInputStream(new FileInputStream(filename));
                                         propSrc = "the specified file : '" + filename + "'";
                                     }
                                     props.load(is);
                                 } catch (IOException ioe) {
                                     initException = new SchedulerException("Properties file: '"
                                             + filename + "' could not be read.", ioe);
                                     throw initException;
                                 }
                    ...
                    

                     

                    So change your properties-service.xml contents to (use the dir property instead of url property):

                     

                    <attribute name="Properties">
                          org.quartz.properties=${jboss.server.home.dir}/conf/my-quartz.properties
                        </attribute>
                    
                    
                    • 7. Re: JBoss AS6 and Quartz 1.8.4 Not Finding Properties
                      jbosslars

                      Fantastic catch - works like a champ! THANK YOU!