Tomcat自动解压WAR文件更改了文件的最后修改时间
当我尝试将 WAR 文件部署到 tomcat 时遇到问题。 在 tomcat 自动解包过程中,解包文件的最后修改日期被修改。 解压 Web 应用程序的日期。文件速度加快了 12 小时,这导致了一些其他错误。
我尝试通过 jar -xvf 手动解压,文件的最后修改日期保持不变。 我还在本地 tomcat 中进行了测试(与开发环境相同的时区),上次修改日期没有任何变化。
看来是tomcat时区问题,我可以在tomcat上进行设置来解决这个问题吗? 非常感谢您的帮助。
环境: Linux 上的 Tomcat 6,服务器和 tomcat 中均设置 GMT-4 时区 设置为 GMT+8 时区的机器创建的 WAR 文件
I experienced an issue when I tried to deploy a WAR file to tomcat.
While the auto unpack process from tomcat, the last modified date of unpack files were being modified.
The date of unpack web app. files became 12 hours faster, and this results several miscellaneous errors.
I tried to unpack manually via jar -xvf, the last modified date of files remain unchanged.
I also tested in a local tomcat (same timezone with dev. env.), nothing changed in last modified date.
It seems the tomcat timezone issue, does setup on tomcat I can do to solve out this issue?
Great thanks for any help.
Environment:
Tomcat 6 on linux, with GMT-4 timezone both set in server and tomcat
the WAR file created by machine with GMT+8 timezone set
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,应用程序在初始化时从 Tomcat 中设置默认时区。时区更改带来的差异与文件修改时间的偏移量相匹配。
令我惊讶的是,应用程序中的任何代码都可以在解包之前运行,但 Tomcat 容器确实为应用程序提供了在解包所有文件之前运行初始化代码的机会。
查找
TimeZone.setDefault()
的出现,并尝试删除该调用或将调用移至初始化序列的稍后位置。有用的线索:
这个 JSP 告诉我,无论环境设置如何,应用程序始终以特定时区运行:
在日志文件中,我可以看到时区更改的瞬间(四小时跳跃)。它发生在应用程序加载时。
注意:设置后,时区将保持设置状态,直到 Tomcat 重新启动。
In my case, the application was setting the default timezone from within Tomcat as the application was being initialized. The difference introduced by the change in timezones matched the offset in the file modification times.
I was surprised that any code within the app could run before being unpacked, but the Tomcat container does give the application an opportunity to run initialization code prior to all files being unpacked.
Look for an occurrence of
TimeZone.setDefault()
and try removing the call or moving the call later in the initialization sequence.Helpful clues:
This JSP told me that the application was always running with a specific timezone regardless of the environment settings:
In the log files, I could see the instant the timezone was changing (four hour jump). It happens at the time the app is loaded.
Note: Once set, the timezone will stay set until Tomcat is restarted.