From: Dave Miller on 15 Dec 2008 22:46 Qu0ll wrote: > "Dave Miller" <nonregistered(a)coldrain.net> wrote in message > news:DQt1l.1990$7I6.542(a)nwrddc01.gnilink.net... >> Qu0ll wrote: >>> I am trying to configure the built-in Java logging within an applet >>> using 6u11 but I encounter the following: >>> >>> java.security.AccessControlException: access denied >>> (java.util.logging.LoggingPermission control) >>> at java.security.AccessControlContext.checkPermission(Unknown >>> Source) >>> at java.security.AccessController.checkPermission(Unknown Source) >>> at java.lang.SecurityManager.checkPermission(Unknown Source) >>> at java.util.logging.LogManager.checkAccess(Unknown Source) >>> at java.util.logging.LogManager.readConfiguration(Unknown Source) >>> at com.test.MyApplet.init(MyApplet.java:50) >>> at >>> sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown >>> Source) >>> at java.lang.Thread.run(Unknown Source) >>> Exception: java.security.AccessControlException: access denied >>> (java.util.logging.LoggingPermission control) >>> >>> The relevant lines in MyApplet are: >>> >>> final LogManager lm = LogManager.getLogManager(); >>> final String s = "handlers=java.util.logging.ConsoleHandler"; >>> final InputStream is = new >>> java.io.ByteArrayInputStream(s.getBytes()); >>> try { >>> lm.readConfiguration(is); >>> } catch (final IOException ioe) { >>> System.err.println(ioe); >>> } >>> >>> The exception is generated when the readConfiguration() is called. >>> This same code works fine in an application. >>> >>> Does Java logging work within applets? How do I get around this >>> exception? >>> >> >> The applet is running within the JRE on the client computer. In the >> unlikely event that you want to print to a log file on the client you >> would need to sign your applet to give it file access permissions. >> (java.security.AccessControlException: access denied ) >> >> If you want your applet to log to the server, you would need to "phone >> home" and capture the output there. > > All I want is to be able to log to the Java console and I thought > ConsoleHandler would do just that. Are you saying that Java logging > can't even do that within an applet? > I misunderstood "logging" to mean that you wanted to write information to a log (file). Unsigned applets can't access client system resources outside of the sandbox (obviously including the file system) ergo my last post. The JRE console is the System.out of the applet. You can print to that with an unsigned applet via System.out.print . -- Dave Miller Java Web Hosting http://www.cheap-jsp-hosting.com/ |