Results 1 to 6 of 6

Thread: How can I prevent Quartz multiple execution after deploy

  1. #1
    Join Date
    Oct 2009
    Posts
    5

    Default How can I prevent Quartz multiple execution after tomcat restart

    hallo,

    we have problem with Quartz.
    Im using tomcat 5.5
    i using 'localhost' to deploy a Spring project on server.
    after deploy run Quartz the job once time. this is right.
    but after restart tomcat, execute the same jobs twice at the same time.
    (2 quartz instanz created and started)

    how can i prevent it?
    follow code are our server.xml code

    ...
    <Host name="localhost" appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    </Host>

    <Host name="XXX.com"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    <Alias>www.XXX.com</Alias>
    <Context path=""
    docBase="/var/lib/tomcat55/webapps/xxx"
    reloadable="true">
    <Realm className="org.apache.catalina.realm.JDBCRealm"
    driverName="org.postgresql.Driver"
    connectionURL="jdbcostgresql://localhost:5432/xxx"
    connectionName="postgres" connectionPassword="" userTable="users_password"
    userNameCol="userid" userCredCol="password"
    userRoleTable="user_role" roleNameCol="rolename"
    digest="MD5"/>
    </Context>
    </Host>
    ...
    Last edited by zlzc2000; Oct 21st, 2009 at 09:44 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    How is quartz configured? What server are you using? Are there more than one application deployed to this server?

  3. #3
    Join Date
    Oct 2009
    Posts
    5

    Default

    Quote Originally Posted by chudak View Post
    How is quartz configured? What server are you using? Are there more than one application deployed to this server?
    i configured in applicationContext.xml:
    <bean id="robotSearchSwapper" class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean">
    <property name="targetObject">
    <ref bean="swapperService" />
    </property>
    <property name="targetMethod">
    <value>robotSearch</value>
    </property>
    <property name="concurrent" value="false" />
    </bean>

    <bean id="robotSearchTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <property name="jobDetail" ref="robotSearchSwapper"/>

    <property name="startDelay">
    <value>180000</value>
    </property>
    <property name="repeatInterval">
    <value>300000</value>
    </property>
    </bean>
    <bean id="scheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="quartzProperties">
    <props>
    <prop key="org.quartz.threadPool.class">org.quartz.simpl .SimpleThreadPool</prop>
    <prop key="org.quartz.threadPool.threadCount">1</prop>
    <prop key="org.quartz.threadPool.threadPriority">1</prop>
    <prop key="org.quartz.threadPool.threadsInheritContextCl assLoaderOfInitializingThread">true</prop>
    </props>
    </property>

    <property name="triggers">
    <list>
    <ref local="robotSearchTrigger"/>
    </list>
    </property>
    </bean>

    Server: tomcat 5.5
    there are only one project with quartz.
    if i delete <host name="localhost" ...> ...</host> of localhost, then well done. but by which i can not use interface of tomcat.

  4. #4
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    I don't understand your last comment...

    When you say that the job is executing more than once: where is the log output showing that this is the case? Did you update your tomcat configuration file between stopping and restarting? Have you tried nuking the working directory for tomcat so that it redeploys your webapp cleanly?

    If your job is running twice, it's probably because it looks like your host configuration is such that it is deploying the application twice...

  5. #5
    Join Date
    Oct 2009
    Posts
    5

    Default

    Quote Originally Posted by chudak View Post
    I don't understand your last comment...

    When you say that the job is executing more than once: where is the log output showing that this is the case? Did you update your tomcat configuration file between stopping and restarting? Have you tried nuking the working directory for tomcat so that it redeploys your webapp cleanly?

    If your job is running twice, it's probably because it looks like your host configuration is such that it is deploying the application twice...
    in server.xml i use two <Host> tags 1: <Host name="localhost" ...> 2:<Host name="XXX.com"...> if i use only one host, for example only <Host name="XXX.com"...>, then no problem.

    with "tail -f /var/log/tomcat55/catalina.out" can i see the log.
    if project new deploy, then no problem, but when i stop tomcat and start tomcat once again, or restart tomcat, then comming problem.

  6. #6
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    http://tomcat.apache.org/tomcat-5.5-...nfig/host.html

    I believe that your tomcat configuration is wrong...because it looks like by having two host elements defined in the way that you have, the application is being deployed TWICE, once for each host entry. This is certainly not what you want.

    When using automatic deployment, the docBase defined by an XML Context file should be outside of the appBase directory. If this is not the case difficulties may be experienced deploying the web application or the application may be deployed twice.

    Finally, note that if you are defining contexts explicitly, you should probably turn off automatic application deployment. Otherwise, your context will be deployed twice each, and that may cause problems for your app.
    If I were you, I'd try turning off the auto deploy for the second host...and point it at the location of the application for the localhost.

    Note that your problem has NOTHING to do with Spring or Quartz for that matter. It is a Tomcat configuration issue and as such you should probably take this question to the tomcat mailing list/forums.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •