【问题标题】:Java not using the correct timezoneJava 没有使用正确的时区
【发布时间】:2017-06-06 16:52:07
【问题描述】:

我的公司有一个 Web 应用程序部署到 Oracle WebLogic 服务器。我们正在努力升级到 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 中。有没有办法在启动参数中指定夏令时?

【问题讨论】:

    标签: java timezone weblogic


    【解决方案1】:

    设置user.timezone 是正确的程序。如果仍然无法正常工作,请尝试升级到最新的 jdk,例如 jdk 7 update 131 或 141。如果这不是一个选项,请尝试“时区更新工具”。您可以在此处找到更多详细信息: http://www.oracle.com/technetwork/java/javase/dst-faq-138158.html

    【讨论】:

    • 无法使用时区更新工具修复此问题,因为它需要 Internet 连接,而此框没有 Internet 连接。至于 JDK 更新,我对如何获得更新 141 有点困惑,因为它不是公开可用的。
    • 我认为下载该工具然后将其复制过来是一种选择,但我以前从未尝试过。如果您有权访问 Oracle 的支持站点,则可以使用更新 141。
    猜你喜欢
    • 2011-05-01
    • 2014-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 1970-01-01
    相关资源
    最近更新 更多