簡體   English   中英

Google App Engine不支持java.util.logging.Logger的子類:com / ibm / icu / impl / ICULogger

[英]Google App Engine does not support subclasses of java.util.logging.Logger: com/ibm/icu/impl/ICULogger

我們正在使用Google App Engine以csv格式發布應用程序中的一些平面數據。 來自可視化數據源庫的Google DataTableCsvRenderer使我們的數據轉換變得容易,並且在本地appengine開發服務器中的測試成功。

部署到我們的appspot實例表明,App Engine不喜歡IBM的ICU庫記錄日志的方式:

Google App Engine不支持java.util.logging.Logger的子類:com / ibm / icu / impl / ICULogger

堆棧跟蹤顯示了起點:

    Caused by: java.lang.SecurityException: Google App Engine does not support subclasses of     java.util.logging.Logger: com/ibm/icu/impl/ICULogger
at com.google.appengine.runtime.Request.process-0b3cd097cad783e6(Request.java)
at java.lang.ClassLoader.loadClass(ClassLoader.java:360)
at com.ibm.icu.util.TimeZone.<clinit>(TimeZone.java:114)

TimeZone的第114行:

/**
 * {@icu} A logger for TimeZone. Will be null if logging is not on by way of system
 * property: "icu4j.debug.logging"
 * @draft ICU 4.4
 * @provisional This API might change or be removed in a future release.
 */
public static ICULogger TimeZoneLogger = ICULogger.getICULogger(TimeZone.class.getName());

我在Eclipse中放置了一個斷點,並在調試器中運行了單元測試,並且由於沒有系統屬性打開日志記錄,因此將TimeZoneLogger分配為null,如進一步所示:

    /**
 * Instantiates a new ICULogger object with logging turned off by default
 * unless the system property "icu4j.debug.logging" is set to "all"
 *
 * @param name to be use by the logger (usually is the class name)
 * @param resourceBundleName name to localize messages (can be null)
 * @return a new ICULogger object
 * @draft ICU 4.4
 * @provisional This API might change or be removed in a future release.
 */
public static ICULogger getICULogger(String name, String resourceBundleName) {
    LOGGER_STATUS flag = checkGlobalLoggingFlag();
    if (flag != LOGGER_STATUS.NULL) {
        ICULogger logger = new ICULogger(name, resourceBundleName);

        /* Add a default handler to logger*/
        logger.addHandler(new ConsoleHandler());

        /* Turn off logging by default unless SYSTEM_PROP_LOGGER property is set to "all" */
        if (flag == LOGGER_STATUS.ON) {
            logger.turnOnLogging();
        } else {
            logger.turnOffLogging();
        }

        return logger;
    }
    return null;
}

我輸入了一些日志記錄語句,以查看是否已實例化TimeZoneLogger,但事實並非如此。

[INFO] Oct 29, 2013 8:45:39 AM  com.example.SomeClass
[INFO] WARNING: icu4j.debug.logging = null
[INFO] Oct 29, 2013 8:45:39 AM com.example.SomeClass
[INFO] WARNING: Time Zone Logger = null

這表明不是App Engine不喜歡的實例化,而僅僅是導致問題的類的引用。

此時,我所能想到的就是編寫自己的CSV渲染器,它是使用違規代碼的類。 花費的精力並不多,但是我更喜歡使用現有的庫...尤其是當庫和平台都來自Google時。

還有其他建議嗎?

您可以提供自己的類的實現來避免此問題。

只需從項目(它是開源的)中獲取com.ibm.icu.util.TimeZone.java文件。 然后將其放入您自己的項目中-保持程序包和類名相同。 然后,“您的”版本將覆蓋jar庫中的版本,您可以對其進行更改。

如果沒有,請檢查項目的構建路徑順序。 在生產服務器上,類在libs之前,因此它也可以工作。

我進行了這些修改,以使其正常工作,但您可能會做出更好的修改:)

第114行:

public static Object TimeZoneLogger = null; // ICULogger.getICULogger(TimeZone.class.getName());

〜780行:也將其注釋掉。

       if (TimeZoneLogger != null && TimeZoneLogger.isLoggingOn()) {
             TimeZoneLogger.warning(
               "\"" +ID + "\" is a bogus id so timezone is falling back to Etc/Unknown(GMT).");
      }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM