Java没有使用正确的时区

时间:2017-06-06 16:52:08

标签: java timezone weblogic

我的公司有一个部署到Oracle WebLogic服务器的Web应用程序。我们正在努力升级到WebLogic 12c并将应用程序从Java 1.5升级到1.7.0_15。

启动应用程序服务器时,我们收到以下错误:

<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
>

我们发现将-Duser.timezone='Canada/Eastern'添加到服务器启动参数可以解决问题。但是,服务器日志和log4j日志没有记录正确的时间戳;他们落后一小时。

我在代码中添加了TimeZone localTimeZone = TimeZone.getDefault();并记录了localTimeZone.toString()并获得了sun.util.calendar.ZoneInfo[id="GMT-05:00",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]

东部标准时间是GMT-5,我们目前处于夏令时,这使它成为GMT-4,因此它似乎使用指定的java启动参数但没有认识到它的假设在夏令时。有没有办法在启动参数中指定DST?

1 个答案:

答案 0 :(得分:0)

设置user.timezone是正确的过程。如果它仍然无法正常工作,请尝试升级到最新的jdk,例如jdk 7 update 131或141.如果这不是一个选项,请尝试使用“Timezone Updater工具”。你可以在这里找到更多细节: http://www.oracle.com/technetwork/java/javase/dst-faq-138158.html