aspose file tools*
The moose likes Tomcat and the fly likes auto deploy and change to DST time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "auto deploy and change to DST time" Watch "auto deploy and change to DST time" New topic
Author

auto deploy and change to DST time

Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
I am working with Tomcat v6.0.18
The attribute for autoDeploy is set to true
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

What is the trigger that informs Tomcat a resource was updated thus a reload should place.
In other words, if I change date/time time on the server will a reload be instigated?
Can someone enlighten me on the mechanism being used.
I am trying to troubleshoot an issue where Tomcat is auto deploying a webapp upon the change in DST time.


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Tomcat scans the webapps periodically looking to see if they have been changed. This is an optional feature, and it can be turned off if you like. On production servers, you may prefer that, since it's extra overhead and (hopefully!) you won't be re-deploying apps all that often on the production server. I think the interval is adjustable. It's not based directly on clock time, but anytime you modify the system clock, all sorts of time-sensitive stuff may be affected, not just Tomcat.

Depending on the OS and how it was set up, however, the OS may not be modifying the hardware clock when Daylight Savings time kicks in. I found that I have a much more pleasant life running the hardware clock on UTC time and letting the OS switch the display time automcatically. Java is getting the UTC time, so it doesn't really care whether it's DST or not.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
Hi Tim,
Can I probe this a little further "Tomcat scans the webapps periodically looking to see if they have been changed".
A change to DST should not have changed the attributes of the webapps.
Tomcat invokes the method checkResources from org.apache.catalina.startup.HostConfig
I am trying to figure what resource is being checked ... is it system time, or something else?
Any pointers would be greatly appreciated.
Tosh.
Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
I think I have found the answer to my own question.


org.apache.catalina.startup.HostConfig

protected synchronized void checkResources(DeployedApplication app) {
String[] resources = (String[]) app.redeployResources.keySet().toArray(new String[0]);
for (int i = 0; i < resources.length; i++) {
File resource = new File(resources[i]);
if (log.isDebugEnabled())
log.debug("Checking context[" + app.name + "] redeploy resource " + resource);
if (resource.exists()) {
long lastModified = ((Long) app.redeployResources.get(resources[i])).longValue();
if ((!resource.isDirectory()) && resource.lastModified() > lastModified) {

. . . .

long java.io.File.lastModified()

lastModified
public long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.

Returns:
A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

Yes... but the fact that the time switches to DST shouldn't affect the value returned by the lastModified() method. As you can see from the documentation you posted, that value is independent of the JVM's default time zone.

However now you can do some experiments with a test base smaller than Apache Tomcat (i.e. a 10-line test program you write yourself) to see whether lastModified() for a file changes when the DST change occurs.
Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
Paul, thanks for the suggestion.
Threw together a simple test java program and it is uncovering some interesting results.
Anyway, thanks for letting me bounce ideas around.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Tosh Bimbra wrote:Threw together a simple test java program and it is uncovering some interesting results.


Like?
Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
Sorry, I should have shared this....
system1 shows a change of 1 hour, while system2 remained the same!
The consequence of this is that webapps on system1 are reloaded once DST is changed, while system2 webapps are not!

system1 running IBM i V6R1
$
cd /tomcat/logs
$
date
Tue Oct 12 14:48:01 Central Daylight Time 2010
$
java GetDirectoryAndFileModifiedTime
Directory name : logs
Directory mod date and time : Tue Oct 12 13:48:59 CDT 2010
$ <==== changed DST date and time here
date
Sun Mar 14 01:58:36 Central Standard Time 2010
$
java GetDirectoryAndFileModifiedTime
Directory name : logs
Directory mod date and time : Tue Oct 12 14:48:59 CDT 2010
$

system2 running IBM iSeries V5R4
$
cd /tomcat/logs
$
date
Tue Oct 12 16:00:49 Central Daylight Time 2010
$
java GetDirectoryAndFileModifiedTime
Directory name : logs
Directory mod date and time : Tue Oct 12 16:00:00 CDT 2010
$ <==== changed DST date and time here
date
Sun Mar 14 01:58:35 Central Standard Time 2010
$
java GetDirectoryAndFileModifiedTime
Directory name : logs
Directory mod date and time : Tue Oct 12 16:00:00 CDT 2010
$"
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

Wow! You actually have two System i machines which you can play around with by changing the system time? Anyway, are you using the exact same system value for the time zone on both? (I don't recall seeing anything about time zones in the changes document for V6R1.) And are you using the same Java version on both?

Edit: Actually I would set up the test more like this:

1. Set the system time to just before the DST switch.

2. Have your application print out the file or directory date every 15 seconds.

3. Let it run past the DST switch and see what changes at that point.

That would simulate what's happening with your Tomcat environment more accurately.
Tosh Bimbra
Greenhorn

Joined: Dec 16, 2009
Posts: 8
Paul,
I will try your suggestion today... the day should pass quickly with all of this fun in testing!
 
Don't get me started about those stupid light bulbs.
 
subject: auto deploy and change to DST time