How-To: Initializing a scheduler within a servlet container

There are two approaches for this which are shown below.

For both cases, make sure to look at the JavaDOC for the related classes to see all possible configuration parameters, as a complete set is not show below.

Adding A Context/Container Listener To web.xml


...
     <context-param>
         <param-name>quartz:config-file</param-name>
         <param-value>/some/path/my_quartz.properties</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:shutdown-on-unload</param-name>
         <param-value>true</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:wait-on-shutdown</param-name>
         <param-value>false</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:start-scheduler-on-load</param-name>
         <param-value>true</param-value>
     </context-param>
...
     <listener>
         <listener-class>
             org.quartz.ee.servlet.QuartzInitializerListener
         </listener-class>
     </listener>
...

Adding A Start-up Servlet 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>
      <load-on-startup>2</load-on-startup>

    </servlet>
...