This is a continuation of the previous article regarding some migration points (1, 2) from JBoss 4.2.2-GA to JBoss 7.1.1 and, presumably, Tomcat 7.
3. Quartz
Quartz migration has been the simplest of all, by far.
3.1 JBoss 4.2.2
In JBoss 4.2.2 Quartz was configured using a MBean with a simple configuration:
<pre lang="xml">
<?xml version="1.0" encoding="UTF-8"??>
<server>
<mbean code="org.quartz.ee.jmx.jboss.QuartzService" name="user:service=QuartzService,name=QuartzService">
<depends>jboss.jca:service=DataSourceBinding,name=XOracleDS</depends>
<depends>jboss.web.deployment:war=/X</depends>
<attribute name="Properties">
org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.xaTransacted = false
...
</attribute>
</mbean>
</server>
3.2 JBoss 7.1.1 and Tomcat 7
However support for the org.jboss.system.ServiceMBeanSupport does not exist anymore. The solution, which works identically in JBoss and Tomcat is to bind the Quartz to the servlet lifecycle using a servlet listener in web.xml:
<pre lang="xml">
<?xml version="1.0" encoding="UTF-8"??>
<web-app>
...
<context-param>
<param-name>quartz:config-file</param-name>
<param-value>/quartz.properties</param-value>
</context-param>
<context-param>
<param-name>quartz:jndi-name</param-name>
<param-value>Quartz</param-value>
</context-param>
...
<listener>
<listener-class>
com.x.web.QuartzInitializerListener
</listener-class>
</listener>
...
</web-app>
All the properties are then provided in a quartz.properties file. I’ve also created a custom listener which is simplified and also binds the Scheduler for access through JNDI.
Comments:
chris -
I have a legacy sar which is trying to bind jndi and failed. Jboss 4 —> Jboss 7 upgrade. Can you show an example of your com.x.web.QuartzInitializerListener how to bind jndi. Any suggestion how to do that inside a sar start() method as well? Thanks
len -
Check the examples from the Quartz website.