Tomcat time zone setting method [go]

Source: Internet
Author: User

Recently, I was asked about the Tomcat time zone setting method, but I haven't encountered any similar problems. It may occur when I record logs and scheduled tasks on the internet. I haven't found it yet. I should record it first.

 

Original article address: http://blog.csdn.net/x_yp/article/details/6234327,the following is the original article:

     

Today in the project encountered a tomcat time and system time inconsistent problem, the Internet found a solution, see the URL: http://evanmin.javaeye.com/blog/849844

 

1. In catalina. bat
The configuration is as follows:

Set JAVA_OPTS = % JAVA_OPTS %-Duser. timezone = GMT + 08-Xms256m-Xmx800m
-Djava. util. logging. manager = org. apache. juli. ClassLoaderLogManager
-Djava. util. logging. config. file = "% CATALINA_BASE %/conf/logging. properties"

-Xms256m-Xmx800m (the initial memory size is 256 MB, and the maximum memory available is 800 MB ),
-Duser. timezone = GMT + 08 // Set to Beijing time

 

After this setting, the time inconsistency problem is solved. However, when Tomcat is put into the Window service and started as a service, the problem may occur. Internet finally found the reason, see the URL: http://www.simpleframework.net/bbs/1443/2121.html

 

As we all know in windows, when a JAVA program is started, the JVM will allocate an initial memory and the maximum memory to this application. The initial memory and maximum memory will affect the performance of the program to a certain extent. For example, when applications use the maximum memory, the JVM needs to first perform garbage collection to release some occupied memory.

Therefore, to adjust the initial memory and maximum memory at Tomcat startup, you must declare to JVM, generally, when running JAVA programs, you can use mid-Xms-Xmx to adjust the initial memory and maximum memory of the application:

For example, java-Xms64m-Xmx128m a. jar.

Tomcat startup programs are packaged and cannot be directly used to change the memory settings using java-X... tomcat. Changing this setting in Tomcat

There are two methods:

1. It is applicable to start with the startup. bat script in % tomcat_home %/bin. You need to add the CATALINA_OPTS attribute to the environment variable.

For example, SET CATALINA_OPTS =-Xms64m-Xmx512m;

Ms is the smallest, mx is the largest, 64 m, m respectively refers to the initial and maximum memory capacity.

Because: startup is used. bat starts the tomcat server and calls catalina. bat file, in Catalian. the related properties set by the system will be loaded under row 166 "rem Execute Java with the applicable properties" of the bat file.

There is % CATALINA_OPTS %. In this way, tomcat will set the memory to the specified value at startup.

2. tomcat is suitable for starting as a system service. At this time, the method for setting the CATALINA_OPTS attribute above is not applicable, because as a system service, % tomcat_home %/bin/tomcat5w.exe is called during system startup, he reads the value in the registry instead of catalina. bat settings, so you need to modify the registry:

Solution:

Modify the registry HKEY_LOCAL_MACHINE/SOFTWARE/Apache Software Foundation/Tomcat Service Manager/Tomcat5/Parameters/JavaOptions

Original value:

-Dcatalina. home = "C:/ApacheGroup/Tomcat 5.0"

-Djava. endorsed. dirs = "C:/ApacheGroup/Tomcat 5.0/common/endorsed"

-Xrs

Add-Xms300m-Xmx350m

Restart the tomcat service and the settings take effect.

Similarly, I add-Duser. timezone = GMT + 08 to the registry to solve the problem.

Tomcat time zone setting method [go]

Related Article

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.