Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:29:28+00:00 2026-06-09T20:29:28+00:00

I have been successfully using quartz in my application. Basically I have quartz bundled

  • 0

I have been successfully using quartz in my application.
Basically I have quartz bundled inside the webapp1 which is running inside the Jboss.

But we have got another webapp2 running in the jboss which needs to have quartz job as well

Now what I need to do is to have quartz scheduler running in the jboss as some kind of service and both the webapps should be able
to register their jobs on the single quartz scheduler.

below is my related spring configuration for webapp1 which has beenworking till now.

<bean id="qtzScheduler"
    class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="dataSource">
        <ref bean="jndiDataSource" />
    </property>
    <property name="applicationContextSchedulerContextKey">
        <value>applicationContext</value>
    </property>
    <property name="transactionManager">
        <ref bean="transactionManager" />
    </property>
    <property name="schedulerName" value="webapp1" />       
</bean>

<bean id="wrapperScheduler" class="uk.fa.quartz.schedule.ServiceScheduler">
    <property name="scheduler">
        <ref bean="qtzScheduler" />
    </property>
</bean>

<bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>java:/FmManagerDS</value>
    </property>
</bean>

when I have to schedule the job,code is like below:

   WrapperScheduler scheduler = (WrapperScheduler) ctx.getBean("wrapperScheduler");
   scheduler.scheduleCronJob(job, jobName + "CronTrigger", WrapperScheduler.TRIGGER_GROUP, cronExpression);

Now I dont want to define the same scheduler again in webapp2 which will cause 2 quartz scheduler running in the jboss.

Can someone has any idea how to do it ?
I saw one example on the internet like below Link which I think is doing what I want.
But I dont understand how I can integrate this with my system using the datasource defined in my spring source.
If anybody can share the configuration or point me to the right resource on internet,I would be highly thankful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:29:30+00:00Added an answer on June 9, 2026 at 8:29 pm

    Finally I got time to write it all down for all others who might have to use Quartz as a service running in jboss.
    But other options as mentioned in his answer by @Tomasz can also be tried.

    Please note that you will get a null reference back if you try to retrieve it from outside the JBoss server in which it was bound. In case you have such a requirement you might want to consider using Quartz’s RMI support instead.

    1)First of all ensure that you remove any existing versions of the quartz in the jboss/[profile]/lib or the quartz.rar which is comes up with the jboss distribution.

    2)Please your quartz.1.8.3.jar & quartz-jboss.1.8.jar into the acccesmanager/[profile]/lib

    3)Below is the code for quartz-service.xml which needs to be placed in the jboss deploy folder which will start the Quartz scheduler:

        <server> 
         <mbean code="org.quartz.ee.jmx.jboss.QuartzService" 
         name="user:service=QuartzService,name=QuartzService">    
         <attribute name="JndiName">Quartz</attribute> 
         <attribute name="Properties">        
         org.quartz.scheduler.instanceName = BGSScheduler 
         org.quartz.scheduler.rmi.export = false 
         org.quartz.scheduler.rmi.proxy = false 
         org.quartz.scheduler.xaTransacted = false 
         org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool  
         org.quartz.threadPool.threadCount = 5 
         org.quartz.threadPool.threadPriority = 4 
         org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true
         org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
         org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
         org.quartz.jobStore.driverDelegateClass =  org.quartz.impl.jdbcjobstore.StdJDBCDelegate
         org.quartz.jobStore.dataSource = QUARTZ
         org.quartz.dataSource.QUARTZ.jndiURL = java:FmManagerDS 
         org.quartz.jobStore.nonManagedTXDataSource = QUARTZ_NO_TX
         org.quartz.dataSource.QUARTZ_NO_TX.jndiURL = java:FmManagerDS
         </attribute>     
         <depends>jboss.jca:service=DataSourceBinding,name=FmManagerDS</depends>
         </mbean> 
         </server>
    

    ]
    Most of things are self explanatory or you can get more details on this at Quartz Configuration
    The key thing is to note that quartz requires 2 datasources.One is the container managed datasource-same one as one defined in jboss *-ds.xml(java:FmManagerDS in my case).
    If your ‘org.quartz.jobStore.dataSource’ is XA, then set ‘org.quartz.jobStore.nonManagedTXDataSource’ to a non-XA datasource (for the same DB). Otherwise, you can set them to be the same.

    Then in spring applicationContext,I had to get the handle of quartz so that I could inject into the wrapperScheduler.Code for that is below

        <bean id="quartzScheduler" class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName">
                    <value>Quartz</value>
                </property>
        </bean>
    
    <bean id="wrapperScheduler" class="k.fa.quartz.schedule.ServiceScheduler">
                <property name="scheduler">
                    <ref bean="quartzScheduler" />
                </property>
        </bean>
    

    Then we can schedule the jobs using below

    Timestamp t = new Timestamp (System.currentTimeMillis());
    ScheduleJob job = new ScheduleJob(EmailJob.class.getCanonicalName() +t.toString(), EmailJob.class);
    

    Below is the code to pass the spring applicationContext to the EmailJob so that we can access beans and other things.
    To achieve that we need to implement the ApplicationContextAware interface so that applicationContext is available and same is then
    pushed into the schedulerContext.Please ensure that we dont put applicationContext into the JobdataMap incase you are using JDBC store as it gives serialization issues.

        serviceScheduler.getScheduler().getContext().put("applicationContext", ctx);
        serviceScheduler.scheduleCronJob(job, "test" + t.toString(), ServiceScheduler.DEFAULT_TRIGGER_GROUP, cronExpression);
    

    Others who are not using wrapperscheduler can similarly get the handle of the quartz directly into their code using below

        InitialContext ctx = new InitialContext();
        Scheduler scheduler = (Scheduler) ctx.lookup("Quartz");
        ScheduleJob job = new ScheduleJob(EmailJob.class.getCanonicalName() +t.toString(), Executor.class);
        scheduler.scheduleJob(job, trigger);
    

    In the Email job class you can use below to get the applicationContext

           applicationContext = (ApplicationContext) context.getScheduler().getContext().get(APPLICATION_CONTEXT_KEY);
           //get spring bean and do the necessary stuff
    

    Another important thing is that as the quartz schedler is running outside the webapplication,quartz wont be able to fire the jobclass if it is inside the war.It needs to be in the shared jar in the jboss/[profile]/lib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Linq-To-Sql based repository class which I have been successfully using. I
I have been successfully running an app under android 2.2 (api8) using spinners with
We have been successfully using protobuf-net v1 in a compact framework application to handle
All these years i have been successfully using EnumServicesStatus in combination with OpenScManager (with
I have successfully been using the eclipse Indigo internal browser to view my web
I have successfully been using Win32::Ole module to browser through pages and submit forms.
I have been using fullcalendar plugin successfully for a few months and suddenly ran
I have been trying to post using RestKit after I have successfully used it
I have started using https://github.com/omab/django-social-auth and been successfully able to login via twitter, google
I have been successfully using my code with the javascript library in the ANTLR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.