I use RAD7 (run time environment WebSphere v6.1) to develop a Enterprice Application myProject. myProject includes a web project myWeb, an EJB project myEJB. I also created a java project commons-logging that imported commons-logging-1.1.1.jar and common-logging.properties file.
this is my logging.properties content:
priority=1
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory
log4j-1.2.15.jar and log4j.properties were imported into root directory of myProject. the log4j.properties contains following lines:
log4j.rootLogger=DEBUG,myAppender
log4j.appender.myAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.myAppender.File=logs/myIcrLog.log
log4j.appender.myAppender.ImmediateFlush=true
log4j.appender.myAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.myAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.myAppender.layout.ConversionPattern=%d [%-5p] (%t) %c: %m%n
In the servlet, I use following statements to call log4j:
Logger log = Logger.getLogger("myLogger");
log.info("start servlet logging...");
I got the error:
[9/22/08 11:07:28:670 CDT] 0000002f ServletWrappe I SRVE0242I: [myProject] [/myWeb] [/myJsp.jsp]: Initialization successful.
[9/22/08 11:07:36:982 CDT] 0000002f ServletWrappe I SRVE0242I: [myProject] [/myWeb] [myServlet]: Initialization successful.
[9/22/08 11:07:36:992 CDT] 0000002f SystemOut O servlet started
[9/22/08 11:07:37:132 CDT] 0000002f SecurityManag W SECJ0314W: Current Java 2 Security policy reported a potential violation of Java 2 Security Permission. Please refer to InfoCenter for further information.
Permission:
getClassLoader : Access denied (java.lang.RuntimePermission getClassLoader)
Code:
org.apache.log4j.helpers.Loader in {file:/C:/Documents and Settings/zs4352/IBM/rationalsdp7.0/workspace/myProject/log4j-1.2.15.jar}
Stack Trace:
java.security.AccessControlException: Access denied (java.lang.RuntimePermission getClassLoader)
at java.security.AccessController.checkPermission(AccessController.java:104)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:547)
at com.ibm.ws.security.core.SecurityManager.checkPermission(SecurityManager.java:189)
at java.lang.Thread.getContextClassLoader(Thread.java:484)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.apache.log4j.helpers.Loader.getTCL(Loader.java:155)
at org.apache.log4j.helpers.Loader.getResource(Loader.java:93)
at org.apache.log4j.LogManager.(LogManager.java:105)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at org.apache.log4j.Logger.getLogger(Logger.java:105)
at myWeb.myServlet.doPost(myServlet.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
Code Base Location:
[9/22/08 11:07:37:192 CDT] 0000002f SecurityManag W SECJ0314W: Current Java 2 Security policy reported a potential violation of Java 2 Security Permission. Please refer to InfoCenter for further information.
Permission:
getClassLoader : Access denied (java.lang.RuntimePermission getClassLoader)
Code:
org.apache.log4j.helpers.Loader in {file:/C:/Documents and Settings/zs4352/IBM/rationalsdp7.0/workspace/myProject/log4j-1.2.15.jar}
Stack Trace:
..............................
By the way, I put log4j.jar and log4j.properties in classpath, and make log4j.jar available to myWeb and myEJB project.
any one know how to fix it? Thanks.
[9/22/08 11:07:37:192 CDT] 0000002f SecurityManag W SECJ0314W: Current Java 2 Security policy reported a potential violation of Java 2 Security Permission. Please refer to InfoCenter for further information.
Permission:
getClassLoader : Access denied (java.lang.RuntimePermission getClassLoader)
------------------------------
As the error message says, look in the docs for further information. You've turned on Java 2 Security, and you'll need to modify .policy files in order to allow log4j to access the classes it needs.
Ken
> ------------------------------
>
> As the error message says, look in the docs for further information.
> You've turned on Java 2 Security, and you'll need to modify .policy
> files in order to allow log4j to access the classes it needs.
>
> Ken
Ot turn off Java 2 security, which in most cases adds overhead but no
value.
It did not work.
It definitely is a classpath problem, however I tried everything it simply did not work.
Anyone can help me?
Thanks in advance.
Did you turn off Java 2 security yet?
several articles mentioned that put log4j.properties under EAR root works for WebSphere v5, but it did not work for WebSphere 6 in my test. I thought I did something wrong!
Do you have any opinion about it?
Ken
Only .jar file could be added to MANIFEST.MF file classpath. How do I add log4j.properties to it?
Ken
Could you explain how to drop log4j.properties into lib\ext in RAD7 development environment?
And I think that log4j.properties should not be global to JVM, because every application need different log4j configuration.
Thanks
Thank you very much. That works well.
Thanks again.
I had a similar issue with websphere v61, but when i checked in application binaries i found no file by name log4j.properties. I am basically websphere admin and doesn't have that much idea logger api's , what should be my next step.
But i am able to see log4j.xml and log4jconfig.xml files in the application binaries.
Please suggest on this.
Thanks.