You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Daling Xu <da...@sonexent.com> on 2002/06/05 15:52:25 UTC

java.security.AccessControlException when use log4j in applet

Hi, All

I am considering using log4j in my project, which is a web-application. I
used
j2sdk1.4, servlet 2.3 and java plug in 1.4, and log4j 1.2.3.  When I use
log4j to log informations in the jsp or servlet, every thing is fine, I can
write to both the console or a file in the server side.

But when I tried to use log4j in the applet side, I got the following
exception (See error message at end), and my applet didn't get loaded.

I tried to trouble-shooting this. It looks that if I change the
log4j.properties file, remove the
appender configuration of the logFile.log, only print out to the console, it
will work.

Is this a bug? How can I fix it?

I understand that in the applet I can't write to a file in the server side.
But I still want to have the flexibility to log to the file from the
servlet. Now it looks that I can only log to console if I want the applet
also use log4j.

Here is the error message from the applet:

java.lang.ExceptionInInitializerError

	at org.apache.log4j.Category.getInstance(Category.java:517)

	at com.myCompany.myProject.myPackage.myApplet.<clinit>(myApplet.java:84)

	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)

	at java.lang.reflect.Constructor.newInstance(Unknown Source)

	at java.lang.Class.newInstance0(Unknown Source)

	at java.lang.Class.newInstance(Unknown Source)

	at sun.applet.AppletPanel.createApplet(Unknown Source)

	at sun.plugin.AppletViewer.createApplet(Unknown Source)

	at sun.applet.AppletPanel.runLoader(Unknown Source)

	at sun.applet.AppletPanel.run(Unknown Source)

	at java.lang.Thread.run(Unknown Source)

Caused by: java.security.AccessControlException: access denied
(java.io.FilePermission logFile.log write)

	at java.security.AccessControlContext.checkPermission(Unknown Source)

	at java.security.AccessController.checkPermission(Unknown Source)

	at java.lang.SecurityManager.checkPermission(Unknown Source)

	at java.lang.SecurityManager.checkWrite(Unknown Source)

	at java.io.FileOutputStream.<init>(Unknown Source)

	at java.io.FileOutputStream.<init>(Unknown Source)

	at org.apache.log4j.FileAppender.setFile(FileAppender.java:272)

	at
org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:156)

	at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:151)

	at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:248)

	at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:124
)

	at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:88)

	at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.jav
a:645)

	at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.jav
a:603)

	at
org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigur
ator.java:524)

	at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:
408)

	at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:
432)

	at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.
java:456)

	at org.apache.log4j.LogManager.<clinit>(LogManager.java:145)

	... 13 more

Thank you very much for any input.

Linda



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: java.security.AccessControlException when use log4j in applet

Posted by James Stauffer <st...@gmail.com>.
You could use a socket appender to send the logs to the server.

On 4/22/06, Swati Das <sw...@yahoo.com> wrote:
> Daling Xu <daling.xu <at> sonexent.com> writes:
>
> >
> > Hi, All
> >
> > I am considering using log4j in my project, which is a web-application. I
> > used
> > j2sdk1.4, servlet 2.3 and java plug in 1.4, and log4j 1.2.3.  When I use
> > log4j to log informations in the jsp or servlet, every thing is fine, I can
> > write to both the console or a file in the server side.
> >
> > But when I tried to use log4j in the applet side, I got the following
> > exception (See error message at end), and my applet didn't get loaded.
> >
> > I tried to trouble-shooting this. It looks that if I change the
> > log4j.properties file, remove the
> > appender configuration of the logFile.log, only print out to the console, it
> > will work.
> >
> > Is this a bug? How can I fix it?
> >
> > I understand that in the applet I can't write to a file in the server side.
> > But I still want to have the flexibility to log to the file from the
> > servlet. Now it looks that I can only log to console if I want the applet
> > also use log4j.
> >
> > >
> Hi,
>
>
> Did you get any solution to this error? I am also facing the same problem.
>
> I am etting a security exception of Write permissions denied when I call log4j
> from an applet, although my
> applet is signed. I am using my applet to write into other files. So why am I
> getting error in this case How can I call log4j from an applet??
>
> Thanks,
> Swati
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: java.security.AccessControlException when use log4j in applet

Posted by Swati Das <sw...@yahoo.com>.
Daling Xu <daling.xu <at> sonexent.com> writes:

> 
> Hi, All
> 
> I am considering using log4j in my project, which is a web-application. I
> used
> j2sdk1.4, servlet 2.3 and java plug in 1.4, and log4j 1.2.3.  When I use
> log4j to log informations in the jsp or servlet, every thing is fine, I can
> write to both the console or a file in the server side.
> 
> But when I tried to use log4j in the applet side, I got the following
> exception (See error message at end), and my applet didn't get loaded.
> 
> I tried to trouble-shooting this. It looks that if I change the
> log4j.properties file, remove the
> appender configuration of the logFile.log, only print out to the console, it
> will work.
> 
> Is this a bug? How can I fix it?
> 
> I understand that in the applet I can't write to a file in the server side.
> But I still want to have the flexibility to log to the file from the
> servlet. Now it looks that I can only log to console if I want the applet
> also use log4j.
> 
> > 
Hi,


Did you get any solution to this error? I am also facing the same problem.

I am etting a security exception of Write permissions denied when I call log4j 
from an applet, although my 
applet is signed. I am using my applet to write into other files. So why am I 
getting error in this case How can I call log4j from an applet??

Thanks,
Swati







---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org