<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Need deployment structure for Quartz job with Spring framework on jboss
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/RizwanP">Rizwan P</a> in <i>Spring Integration</i> - <a href="http://community.jboss.org/message/540953#540953">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello,</p><p>Currently my requirement is to deploy the Quartz jobs with Spring framework, executed via cron trigger.</p><p>I have managed to derive the job, trigger and springContext.xml file for this task. Also, I am getting the desired result as a stand-alone application when executed via a testclient's main method.</p><p>Now, i need the help in deploying this on the Jboss server environment and I am stuck as don't want to deploy it as WAR.</p><p>Any suggestiion or help is very much appreciated, please help</p><p>Below are the code components i have attached for the reference.</p><p><br/>import org.quartz.JobExecutionContext;<br/>import org.quartz.JobExecutionException;</p><p><br/>public interface JobInterface {</p><p> public void init(JobExecutionContext jobExecutionContext)<br/>&#160;&#160; throws JobExecutionException;</p><p> public void execute() throws JobExecutionException;</p><p> public void destroy();</p><p>}</p><p><br/>Implementation class :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import org.quartz.JobExecutionContext;<br/>import org.quartz.JobExecutionException;</p><p>public class RemoveJob implements JobInterface{</p><p> @Override<br/> public void destroy() {<br/>&#160; // TODO Auto-generated method stub clearance<br/>&#160; System.out.println("Inside destroy");<br/> }</p><p> @Override<br/> public void execute() throws JobExecutionException {<br/>&#160; // TODO Auto-generated method stub&#160; actuall job<br/>&#160; System.out.println("Inside execute");<br/> }</p><p> @Override<br/> public void init(JobExecutionContext jobExecutionContext)<br/>&#160;&#160; throws JobExecutionException {<br/>&#160; // TODO Auto-generated method stub initialization stuff<br/>&#160; System.out.println("Inside init");<br/> }</p><p>}</p><p><br/>Delegator class <br/>&#160;&#160; </p><p>public class DelegatingJobBean extends QuartzJobBean{<br/> private static final String App_Key = "applicationContext";<br/> private static final String Job_Key = "job.bean.name";<br/>// /protected org.apache.commons.logging.Log log = LogFactory.getLog(getClass());</p><p> @Override<br/> protected void executeInternal(JobExecutionContext ctx)<br/>&#160;&#160; throws JobExecutionException {<br/>&#160; // TODO Auto-generated method stub<br/>&#160; System.out.println("Inside executeInternal.............");<br/>&#160; SchedulerContext schdContext = null;<br/>&#160; try<br/>&#160; {<br/>&#160;&#160; schdContext = ctx.getScheduler().getContext();<br/>&#160;&#160; <br/>&#160; }catch(SchedulerException e)<br/>&#160; {<br/>&#160;&#160; throw new JobExecutionException("Failure accesssing scheduler context ");<br/>&#160; }<br/>&#160; <br/>&#160; ApplicationContext appContext = (ApplicationContext)schdContext.get(App_Key);<br/>&#160; <br/>&#160; String jobBeanName = (String)ctx.getJobDetail()<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; .getJobDataMap().get(Job_Key);<br/>&#160; <br/>&#160; //log.info("Starting Job : " +jobBeanName);<br/>&#160; <br/>&#160; JobInterface jobBean&#160; =(JobInterface)appContext.getBean(jobBeanName);<br/>&#160; <br/>&#160; <br/>&#160; try<br/>&#160; {<br/>&#160;&#160; jobBean.init(ctx);<br/>&#160;&#160; jobBean.execute();<br/>&#160; }finally<br/>&#160; {<br/>&#160;&#160; jobBean.destroy();<br/>&#160; }<br/>&#160; <br/> }</p><p>}</p><p>Config File</p><p><br/>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br/>&lt;beans xmlns="<a class="jive-link-external-small" href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"<br/> xmlns:xsi="<a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"<br/> xsi:schemaLocation="<a class="jive-link-external-small" href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a class="jive-link-external-small" href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</a>"<br/>&#160;&#160;&#160; &gt;<br/> &lt;!--&#160; This is your job bean<br/>&#160; --&gt;<br/> &lt;bean id="removeExpireBean"<br/>&#160; autowire="byName" lazy-init="default" dependency-check="default"&gt;<br/>&#160; &lt;!--&#160; Ref to other beans. Add more if needed <br/>&#160; --&gt;<br/>&#160; &lt;!--&lt;property name="serviceLocator"&gt;<br/>&#160;&#160; &lt;ref bean="serviceLocator" /&gt;<br/>&#160; &lt;/property&gt;<br/> --&gt;&lt;/bean&gt;<br/> &lt;!--<br/>&#160; Define the bean that delegates the work to the real job bean<br/> --&gt;<br/> &lt;bean name="removalJob"<br/>&#160; lazy-init="default" autowire="default" dependency-check="default"&gt;<br/>&#160; &lt;property name="jobClass" value="DelegatingJobBean" /&gt;<br/>&#160; &lt;property name="jobDataAsMap"&gt;<br/>&#160;&#160; &lt;map&gt;<br/>&#160;&#160;&#160; &lt;!--&#160; This specifies the actual job bean name <br/>&#160; --&gt;<br/>&#160;&#160;&#160; &lt;entry key="job.bean.name" value="removeExpireBean" /&gt;<br/>&#160;&#160;&#160; &lt;!--&#160; Any other job data map entries required by your job <br/>&#160; --&gt;<br/>&#160;&#160;&#160; &lt;entry key="sdtl.file.prefix" value="sdtl_" /&gt;<br/>&#160;&#160; &lt;/map&gt;<br/>&#160; &lt;/property&gt;<br/> &lt;/bean&gt;<br/> &lt;!--&#160; Associate the delegating job bean with a trigger <br/>&#160; --&gt;<br/> &lt;bean id="removalTrigger"<br/>&#160; lazy-init="default" autowire="default" dependency-check="default"&gt;<br/>&#160; &lt;property name="jobDetail" ref="removalJob" /&gt;<br/>&#160; &lt;!--&#160; run every morning at 6:30 AM <br/>&#160; --&gt;<br/>&#160; &lt;property name="cronExpression" value="0/10 * * * * ?" /&gt;<br/> &lt;/bean&gt;<br/> &lt;!--&#160; Define the scheduler with the list of triggers <br/>&#160; --&gt;<br/> &lt;bean<br/>&#160; lazy-init="default" autowire="default" dependency-check="default"&gt;<br/>&#160; &lt;property name="triggers"&gt;<br/>&#160;&#160; &lt;list&gt;<br/>&#160;&#160;&#160; &lt;ref bean="removalTrigger" /&gt;<br/>&#160;&#160; &lt;/list&gt;<br/>&#160; &lt;/property&gt;<br/>&#160; &lt;!--&#160; Scheduler context key we use this in delegating job bean <br/>&#160; --&gt;<br/>&#160; &lt;property name="applicationContextSchedulerContextKey"&gt;<br/>&#160;&#160; &lt;value&gt;applicationContext&lt;/value&gt;<br/>&#160; &lt;/property&gt;<br/> &lt;/bean&gt;<br/>&lt;/beans&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please suggest the deployment structure to be follw to work with this..</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/540953#540953">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Spring Integration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>