简体   繁体   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

We are using Google App Engine to publish some flat data from our application in a csv format. 我们正在使用Google App Engine以csv格式发布应用程序中的一些平面数据。 Google's DataTable and CsvRenderer from visualization-datasource library made the conversion of our data easy and testing succeeded in the local appengine development server. 来自可视化数据源库的Google DataTableCsvRenderer使我们的数据转换变得容易,并且在本地appengine开发服务器中的测试成功。

Deploying to our appspot instance exposed that App Engine does not like the way IBM's ICU library is Logging: 部署到我们的appspot实例表明,App Engine不喜欢IBM的ICU库记录日志的方式:

Google App Engine does not support subclasses of java.util.logging.Logger: com/ibm/icu/impl/ICULogger Google App Engine不支持java.util.logging.Logger的子类:com / ibm / icu / impl / ICULogger

The stack trace shows the point of origin: 堆栈跟踪显示了起点:

    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)

Line 114 of TimeZone: 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());

I put a breakpoint in Eclipse and ran the unit tests in the debugger and TimeZoneLogger is being assigned null since there is no System property turning on the logging as seen further: 我在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;
}

I put in some logging statements to see if TimeZoneLogger was being instantiated and it shows it is not. 我输入了一些日志记录语句,以查看是否已实例化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

This shows that it's not the instantiation that App Engine doesn't like, but simply the reference to the class that causes the problem. 这表明不是App Engine不喜欢的实例化,而仅仅是导致问题的类的引用。

At this point all I can think of is to write my own CSV Renderer which is the class using the violating code. 此时,我所能想到的就是编写自己的CSV渲染器,它是使用违规代码的类。 The effort would not be significant, but I would prefer to use existing libraries...especially when the library and platform both come from Google. 花费的精力并不多,但是我更喜欢使用现有的库...尤其是当库和平台都来自Google时。

Any other suggestions? 还有其他建议吗?

You can provide your own implementation of the class to avoid this issue. 您可以提供自己的类的实现来避免此问题。

Simply take the com.ibm.icu.util.TimeZone.java file from the project (It's open source). 只需从项目(它是开源的)中获取com.ibm.icu.util.TimeZone.java文件。 Then put it into your own project - keeping the package and class name the same. 然后将其放入您自己的项目中-保持程序包和类名相同。 "Your" version will then override the one from the jar library and you can change it. 然后,“您的”版本将覆盖jar库中的版本,您可以对其进行更改。

If it doesn't then check your build path order for the project. 如果没有,请检查项目的构建路径顺序。 On the productive server classes are before libs so it will also work. 在生产服务器上,类在libs之前,因此它也可以工作。

I made these hacky modifications to get it to work but you might make better ones :) 我进行了这些修改,以使其正常工作,但您可能会做出更好的修改:)

line ~114: 第114行:

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

line ~780: comment this out too. 〜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