Troubleshooting
Problem
Resolving The Problem
When there are problems with the time value returned to an application or written to the log files, a simple test can determine if the problem is with system configuration or the Java SDK timezone offset values.
Collecting data
Running the Automated Script (os_timezone.[bat|sh])
- To collect both the Java information and the system information, you can use the provided os_timezone.[bat|sh] script provided at the bottom of this document.
NOTE: This script does not run the time.jsp, which has to be first inserted into an EAR file and then accessed separately either in a web browser, or (on UNIX or Linux) by using the commands wget or curl.
Setup- Download the following files to the same directory
· os_timezone.[bat|sh]
· TimeTest.class
If you want to compile your own version of the TimeTest.class, download the .java file.
- Before you start, look at a wall clock and document the time (and your time zone) when you started the test.
os_timezone.[bat|sh] [JAVA_HOME]
JAVA_HOME is the path to the root of the Java directories (usually the folder named "java"). For example, /usr/IBM/WebSphere/AppServer/java/ is a valid path.
Because the script outputs both stdout and stderr, when you redirect output to a file, you need to add an extra argument to the end of the line:
os_timezone.[bat|sh] [JAVA_HOME] > output.txt 2>&1
NOTE: For UNIX/Linux, make sure that you set the permissions on the script file so it's executable.
What the script runs...- For your reference, here is a summary of the commands run by the script:
- AIX, HP-UX, Linux, Solaris
date echo $TZ (Linux only) ls -al /etc/localtime (Linux only) ls -al /etc/timezone (Linux only) grep ZONE /etc/sysconfig/clock [JAVA_HOME]/jre/bin/java -version [JAVA_HOME]/jre/bin/java -cp . TimeTest
- Windows
date /T time /T tzutil /g w32tm /TZ [JAVA_HOME]\jre\bin\java -version [JAVA_HOME]\jre\bin\java -cp . TimeTest
- Download the following files to the same directory
Running the JSP file (time.jsp)
IBM WebSphere Application Server test by using time.jsp. To test the application server, you have two options:
- A. Insert time.jsp into existing application
- Insert the time.jsp file (attachment can be found at the end of this document) to an existing application.
- To run time.jsp, put the file in the install_root/installedApps/node_name/EAR_directory/WAR_directory for an existing application. One of the sample applications that comes with WebSphere Application Server, such as DefaultApplication.
- Request time.jsp from a browser. By default (for the DefaultApplication) it is http://localhost:9080/time.jsp, but you might need to add a context-root to the URL (check the web.xml for what the context-root is for the EAR/WAR). NOTE: Replace localhost:9080 with the desired host and port
- B. Deploy the EAR file
- Download and deploy the TimeMustgather.ear at the bottom of this document.
- Start the application
- In a browser, go to http://localhost:9080/TimeMustgather/time.jsp to launch the JSP.
- The results display in the browser (which lists all valid time zones that the SDK knows about) and more details about the current time zone are written to the application server log file, SystemOut.log.
Save the webpage and send in the HTML file as part of the data collection.
Screen capture of the webpage:
In the SystemOut.log file, after time.jsp is launched, the following information displays, which is similar to the output of TimeTest.class:
[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U Fri Apr 09 12:43:15 EDT 2004
[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U java.util.SimpleTimeZone[id=America/New_York,
offset=-18000000,
dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,
startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,
startTimeMode=0,endMode=2,endMonth=9,
endDay=-1,endDayOfWeek=1,
endTime=7200000,endTimeMode=0]
[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U America/New_York [4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U Eastern Standard Time
[4/9/04 12:43:15:181 EDT] 58c81942 SystemOut
Currently in Daylight Saving Time.
Manual Steps
Gathering System Information (command-line)
Look at a wall clock and document the time you started the data capture (note the time zone you are in).
The following commands help determine the time zone setting that the operating system is using:
For Windows® system:
Take a screen capture of the Date and Time dialog, at Control Panel > Date and Time
Also, run these commands from the command line
For UNIX® systems, issue the following commands from a command line to display the time zone:
date
echo $TZ
date
ls -al /etc/localtime
ls -al /etc/timezone
grep ZONE /etc/sysconfig/clock
The files local time and time zone are usually symbolic links to the appropriate time zone file, but it is not always the case, as different flavors of Linux handle time zones differently. If you have access to the GUI, you can also open up the date and time settings and take a screen capture.
Java stand alone test (TimeTest.class)
- Copy the TimeTest.class file (attachment can be found at the end of this document) to a temporary directory.
- From the command window, navigate to this temporary directory.
- Locate your Java executable and note the path, for example:
-
/usr/IBM/WebSphere/AppServer/java/
- Run the command, supplying the full path to the Java executable:
<JAVA_PATH>/jre/bin/java -cp . TimeTest
- Obtain the current Java version, also supplying the full path to the Java executable:
<JAVA_PATH>/jre/bin/java -version
NOTE: If you place TimeTest.class in the directory where the Java executable resides, you don't need to supply the classpath argument, "-cp ."
The TimeTest.java source code is provided if you would like to recompile it, which may be necessary in some cases.
Output of TimeTest.class
This outputs to the standard out (usually the command line) when TimeTest.class is run.
-
Fri Apr 09 12:45:11 EDT 2004 java.util.SimpleTimeZone[id=America/New_York,offset=-18000000, dstSavings=3600000,useDaylight=true,startYear=0,startMode=3, startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000, startTimeMode=0,endMode=2,endMonth=9, endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0] America/New_York Eastern Standard Time Currently in Daylight Saving Time.
Meaning of the parameters are documented in the Java doc API:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/SimpleTimeZone.html
Some of the parameters have special rules, so refer to the API for more information. Also, note that some values can be negative.
Further details about the values are found in the Additional Information section.
Data to Upload to Support
- Time on wall clock when you capture data (note your time zone)
- WebSphere Application Server logs
- SystemOut.log
- SystemErr.log
- native_stdout.log
- native_stderr.log
- Java version information (./java -version)
- You can also capture a javacore from the running JVM.
- Java command line arguments (can be obtained from the javacore, server.xml, or from the process list)
- HTML output of time.jsp
- Output from running os_timezone script
- If ran TimeTest.class stand-alone, supply the command line you ran along with the output.
- If ran TimeTest.class stand-alone, supply the command line you ran along with the output.
Additional Information
- Displaying the current values that the JVM™ is using
The attached JSP™ file, time.jsp, can be deployed on any application that shows symptoms of reporting the incorrect time. When time.jsp is called, it returns the following values:
- Current date and time
- Time zone ID
- Long name of the time zone in use
- Currently in/not in Daylight Saving Time.
- A table of time zone information that is available with the SDK that is in use.
ID | A String giving the time zone identifier (for example, America/New_York) |
offset | An integer field giving the offset in milliseconds from GMT (or UTC). The number represents the number of milliseconds that must be added to GMT time to obtain the time in this zone. For example, the US/Eastern zone has a value of -18000000. To determine the offset in hours, offset = -18000000/( 60 * 60 * 1000). |
dstSavings | An integer field giving the additional offset from GMT (or UTC) in milliseconds. (The time is calculated as offset + GMT). |
useDaylight | Boolean field set to indicate if the time zone switches to DST. |
startYear | An integer indicating the year in which the specified Daylight Saving Time rule took effect. |
startMonth |
An integer field giving the month of the year in which Daylight Saving Time starts. 0/January, 1/February, 2/March, 3/April, 4/May, 5/June, 6/July, 7/August, 8/September, 9/October, 10/November, 11/December.
|
startDay | An integer giving the daylight saving ending day of the week occurrence in the month; where 1 means first occurrence, 2 means second, -1 means last occurrence, -2 means second to last occurrence, and so on. When startDayOfWeek is zero, this field represents a specific date in the month. Moreover, if startDayOfWeek is negative, this field indicates the day of the month after which the day of the week indicated by the absolute value of startDayOfWeek marks the start of Daylight Saving Time. |
startDayOfWeek | An integer field indicating the day of the week for ending Daylight Saving Time, where 1 is Sunday and 7 is Saturday. There are some twists allowed as indicated in the startDay description. |
startTime | An integer field giving the time of day in milliseconds, starting at midnight, at which Daylight Saving Time starts. (startTime = 7200000 / 60 * 60 * 1000). |
endMonth | Same as startMonth, but for the end of Daylight Saving Time. |
endDay | Same as startDay, but for the end of Daylight Saving Time. |
endDayOfWeek | Same as startDayOfWeek, but for end of Daylight Saving Time. |
endTime | Same as startTime, but for end of Daylight Saving Time. |
- If you want to specify a specific time zone that is not the same as the operating system, set the following generic JVM argument:
-Duser.timezone=ID
An example of setting the time zone to America/Los_Angeles is:
-Duser.timezone=America/Los_Angeles
NOTE: Valid time zone values display in a table when- time.jsp is requested.
- time.jsp is requested.
- Applying the time zone updates by using the JTZU tool
- You can update only the time zone database in each SDK installed using the JTZU tool. For more information on this tool, navigate to the following pages:
- Changes to Daylight Saving Time
http://www.ibm.com/developerworks/java/jdk/dst/index.html - Olson time zone updates for Java JRE and SDK service refreshes for IBM products
http://www.ibm.com/developerworks/java/jdk/dst/olson_table.html - IBM Time Zone Update Utility for Java - Version X.X.XXX
http://www.ibm.com/developerworks/java/jdk/dst/jtzu.html
- Changes to Daylight Saving Time
- Upgrading to the latest SDK includes the updated time zone database (as per these charts) along with the SDK. Consult your product's support pages for upgrade details and fix pack downloads.
- You can update only the time zone database in each SDK installed using the JTZU tool. For more information on this tool, navigate to the following pages:
Related Information
Was this topic helpful?
Document Information
Modified date:
23 April 2024
UID
swg21173447