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