NPE with logging while launching webstart on jre7 update 40
Asked Answered
A

2

8

My application was running fine until I upgraded my jre to 7u40. When my application is initializing, it's doing Logger.getLogger("ClassName"), and I'm getting the following exception.

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)

The exception is coming from this line:

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

Could it be because of any sideeffects with fix https://bugs.java.com/bugdatabase/view_bug?bug_id=8017174 ?

A workaround is to open the java control center and enable logging. This is a concern since by default "Enable Logging" is unchecked. If I select "Enable Logging", the application starts fine.

America answered 24/9, 2013 at 8:56 Comment(2)
Opened bugs.sun.com/view_bug.do?bug_id=9007085America
Related: java-util-logger-logger-getanonymouslogger-throws-nullpointerexceptionSpain
A
1

This problem seems to be fixed in java7 update 45.

America answered 22/10, 2013 at 5:47 Comment(0)
K
0

Try to package java.util.logging.* with your app in a JAR, and make sure it's on the classpath. That way it is always available. Also, what does your logging.properties look like?

Kep answered 22/10, 2013 at 3:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.