Announcement Announcement Module
Collapse
No announcement yet.
Spring-managed Quartz starting multiple threads... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-managed Quartz starting multiple threads...

    Hi,

    I suspect I am doing something really silly here (usually the case).

    I have Spring starting up a CronTriggerBean like this:

    Code:
    <bean id="quartzSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="triggers">
    		<list>
    			<ref bean="cronEmailTrigger"/>
    		</list>
    	</property>
    	
    	<property name="autoStartup" value="true" />
    	<property name="applicationContextSchedulerContextKey" value="applicationContext" />
    	<property name="waitForJobsToCompleteOnShutdown" value="true" /> 
    </bean>
    My cron setup is like this:
    Code:
    email.CronTriggerExpression=0 * * * * ?
    (i.e. every minute)

    However, when I start up Tomcat, instead of getting one job triggering every minute, I get 3 identical jobs starting up.

    This is causing no end of problems as you can imagine. It looks like 3 instances of Quartz are being started up.

    Anyone else come across this?

    In case it helps, here is my Tomcat server.xml:

    Code:
    <?xml version='1.0' encoding='utf-8'?>
    
    <Server port="8005" shutdown="SHUTDOWN">
    
      <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      <Listener className="org.apache.catalina.core.JasperListener" />
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    
      <GlobalNamingResources>
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved"
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                  pathname="conf/tomcat-users.xml" />
      </GlobalNamingResources>
    
      <Service name="Catalina">
        
        <Connector port="80" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   redirectPort="8443" />
    
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    
        <Engine name="Catalina" defaultHost="website.co.uk">
    
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 resourceName="UserDatabase"/>
    
          <Host name="website.co.uk" debug="0" appBase="webapps"
                 unpackWARs="true" autoDeploy="false"
                 xmlValidation="false" xmlNamespaceAware="false">
                  
                  <Alias>w-w-w.website.co.uk</Alias>       
                  
                  <Logger className="org.apache.catalina.logger.FileLogger"
                           directory="logs"  prefix="website_log." suffix=".txt"
                      timestamp="true"/>  
                      
          	<Context path="/" docBase="/Website" debug="0" reloadable="true"/>                  
          </Host>
        
          <Host name="websitefe.co.uk" debug="0" appBase="webapps"
                 unpackWARs="true" autoDeploy="false"
                 xmlValidation="false" xmlNamespaceAware="false">
                  
                  <Alias>w-w-w.websitefe.co.uk</Alias>       
                  
                  <Logger className="org.apache.catalina.logger.FileLogger"
                           directory="logs"  prefix="websitefe_log." suffix=".txt"
                      timestamp="true"/>  
                      
          	<Context path="/" docBase="/WebsiteFE" debug="0" reloadable="true"/>  
          	
    	<Resource name="jdbc/website" auth="Container" type="javax.sql.DataSource"
    		       maxActive="100" maxIdle="30" maxWait="10000"
    		       username="website" password="website" driverClassName="com.mysql.jdbc.Driver"
    		       url="jdbc:mysql://localhost:3306/website?autoReconnect=true"/>      	
          </Host>  
          
        </Engine>
      </Service>
    </Server>
    (the w-w-w bit is just because this forum won't let me put URLs in).

    Many thanks for any suggestions,

    James.

  • #2
    Sorted...

    Hi,

    Well, I've found a solution (or at least a work-around). I've found that putting:

    Code:
    deployOnStartup="false"
    in the <Host> tag in server.xml seems to fix the problem.

    James

    Comment

    Working...
    X