From: Qu0ll on
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?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour(a)gmail.com
[Replace the "SixFour" with numbers to email me]

From: Dave Miller on
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.

--
Dave Miller
Java Web Hosting
http://www.cheap-jsp-hosting.com/
From: Qu0ll on
"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?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour(a)gmail.com
[Replace the "SixFour" with numbers to email me]

From: Daniel Pitts on
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?
>
It can if you sign your applet. It's not actually that hard of a
process to do. I used to be afraid of it, but I found many helpful pages
by using Google.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
From: Andrew Thompson on
On Dec 16, 4:43 am, "Qu0ll" <Qu0llSixF...(a)gmail.com> wrote:
....
> 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?

Try an anonymous logger. They should work in
sandboxed applets.

--
Andrew Thompson
http://pscode.org/