简体   繁体   中英

Java not using the correct timezone

My company has a web application deployed to an Oracle WebLogic server. We are working on upgrading to WebLogic 12c and upgrading the application from Java 1.5 to 1.7.0_15.

When starting the application server, we were getting the following error:

<Jun 6, 2017 12:09:31 PM EDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "SIMPLeBDataSource" due to error weblogic.application.ModuleException: weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection for datasource 'SIMPLeBDataSource'. The DBMS driver exception was: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region  not found

weblogic.application.ModuleException: weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection for datasource 'SIMPLeBDataSource'. The DBMS driver exception was: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region  not found

        at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:350)
        at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
        at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
        at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        Truncated. see log file for complete stacktrace
Caused By: weblogic.common.ResourceException: weblogic.common.ResourceException: Could not create pool connection for datasource 'SIMPLeBDataSource'. The DBMS driver exception was: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region  not found

        at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:360)
        at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1320)
        at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1237)
        at weblogic.common.resourcepool.ResourcePoolImpl.start(ResourcePoolImpl.java:240)
        at weblogic.jdbc.common.internal.ConnectionPool.doStart(ConnectionPool.java:1624)
        Truncated. see log file for complete stacktrace
>

We found that adding -Duser.timezone='Canada/Eastern' to the server start parameters fixed the problem. However, the server logs and log4j logs are not recording the correct timestamp; they are an hour behind.

I added TimeZone localTimeZone = TimeZone.getDefault(); to the code and logged localTimeZone.toString() and got sun.util.calendar.ZoneInfo[id="GMT-05:00",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] .

Eastern Standard Time is GMT-5 and we are currently in Daylight Savings, which makes it GMT-4, so it seems like it's using the specified java startup parameter but not recognizing that it's supposed to be in DST. Is there a way to specify DST in the start parameters?

Setting user.timezone is the correct procedure. If its still not working, try upgrading to the latest jdk, say jdk 7 update 131 or 141. If that is not an option, try the "Timezone Updater tool". You can find more details here : http://www.oracle.com/technetwork/java/javase/dst-faq-138158.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM