Analysis on the trigger triggered when a spring timer is called

Source: Internet
Author: User

The timer is widely used. I have used it many times before, but today, when I re-wrote a timer, it was very strange.
A method is triggered at a time point, but this method is called twice. I checked the program carefully and did not trigger it multiple times, did not start multiple tomcat servers, and did not check for any problems. later, I saw a post posted by experts on the Internet and found that the original reasons were as follows:
This error is caused by improper configuration of the TOMCAT configuration file server. xml. Please refer to the following configuration section:
 
[Html]
<Host name = "www. ***. com "debug =" 0 "appBase =" webapps "unpackWARs =" true "autoDeploy =" true "xmlValidation =" false "xmlNamespaceAware =" false ">
<Logger className = "org. apache. catalina. logger. FileLogger" directory = "logs" prefix = "localhost_log." suffix = ". txt" timestamp = "true"/>
<Context path = "" docBase = "/tomcat/webapps/***" debug = "1"/>
<Context path = "/*** 2" docBase = "/tomcat/webapps/*** 2" debug = "1"/>
</Host>

The correct configuration is as follows:
[Html]
<Host name = "www. ***. com "debug =" 0 "appBase =" "unpackWARs =" true "autoDeploy =" true "xmlValidation =" false "xmlNamespaceAware =" false ">
<Logger className = "org. apache. catalina. logger. FileLogger" directory = "logs" prefix = "localhost_log." suffix = ". txt" timestamp = "true"/>
<Context path = "" docBase = "/tomcat/webapps/***" debug = "1"/>
<Context path = "/*** 2" docBase = "/tomcat/webapps/*** 2" debug = "1"/>
</Host>

The difference between the two sections is that the second section removes the webapps in appBase = "webapps" and changes them to appBase = "", because the web applications are all stored in the webapps directory, if "webapps" is not removed, a quartz task scheduling will be called here, and a quartz task scheduling will be called in the next "<Context path, so I repeat it twice.
 
This situation is generally caused by the compiler automatically adding paths, such as compiling with eclipse, releasing programs, or manually adding project paths. Check the tomcat configuration to avoid this problem.
Author: eminem2011

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.