在jre7 update 40上启动webstart时进行日志记录的NPE

时间:2013-09-24 08:56:17

标签: java logging java.util.logging

我的应用程序运行正常,直到我将jre升级到7u40。当我的应用程序正在初始化时,它正在执行Logger.getLogger(“ClassName”),并且我得到以下异常。

java.lang.ExceptionInInitializerError
    at java.util.logging.Logger.demandLogger(Unknown Source)
    at java.util.logging.Logger.getLogger(Unknown Source)
    at com.company.Application.Applet.<clinit>(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javaws.Launcher.executeApplication(Unknown Source)
    at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NullPointerException
    at java.util.logging.Logger.setParent(Unknown Source)
    at java.util.logging.LogManager$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.doSetParent(Unknown Source)
    at java.util.logging.LogManager.access$1100(Unknown Source)
    at java.util.logging.LogManager$LogNode.walkAndSetParent(Unknown Source)
    at java.util.logging.LogManager$LoggerContext.addLocalLogger(Unknown Source)
    at java.util.logging.LogManager$LoggerContext.addLocalLogger(Unknown Source)
    at java.util.logging.LogManager.addLogger(Unknown Source)
    at java.util.logging.LogManager$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.<clinit>(Unknown Source)

例外是来自这条线:

private static Logger logger = Logger.getLogger(Applet.class.getName());

可能是因为修复http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017174会产生任何副作用吗?

解决方法是打开java控制中心并启用日志记录。这是一个问题,因为默认情况下未选中“启用日志记录”。如果我选择“启用日志记录”,则应用程序启动正常。

2 个答案:

答案 0 :(得分:1)

这个问题似乎在java 7 update 45中得到修复。

答案 1 :(得分:0)

尝试将java.util.logging.*与您的应用打包在一个JAR中,并确保它在类路径中。这样它总是可用的。另外,您的logging.properties是什么样的?