问题
I just upgraded my Java plugin to 1.7.0_25, which caused a fatal error with an applet I wrote several years ago (and have been maintaining since).
Early in the applet's init() method I call
logger = Logger.getAnonymousLogger();
This call has been running since Java 1.4.2 without a problem. Now, with Java 1.7.0_25 (on Windows 7 at least; I've no Mac or Linux machine to test with here), the first time the applet is loaded, it works just fine. However if the applet's browser page is closed and the page loaded again, the applet fails with the following console message:
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 756747 us, pluginInit dt 76093467 us, TotalTime: 76850214 us java.lang.NullPointerException
at java.util.logging.Logger.doSetParent(Unknown Source)
at java.util.logging.Logger.getAnonymousLogger(Unknown Source)
at java.util.logging.Logger.getAnonymousLogger(Unknown Source)
at com.optix.applet.viewer.ObjectViewer.init(ObjectViewer.java:214)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ignored exception: java.lang.NullPointerException
To load the applet again, I must close and restart the browser.
This has never happened with any previous Java release since java.util.logger was introduced in Java 1.4.
There should be no permissions problem: I've added to META-INF/MANFEST.MF the new attributes
Permissions: all-permissions
Codebase: *
as called for in http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/no_redeploy.html. The applet is signed with a current GoDaddy certificate and timestamped.
I found that if I create the logger with
logger = Logger.getLogger(String);
the applet will load every time.
I can find nothing on this error. Has anyone seen it? Would anyone know what caused it to appear with Java 1.7.0_25 or why the call would work once in a browser session but not a second time?
回答1:
I have exactly the same problem on Linux.
This is the relevant bug report from Oracle.
来源:https://stackoverflow.com/questions/17241970/java-util-logger-logger-getanonymouslogger-throws-nullpointerexception