Packaging and isolating log4j in a WAR file
pdesj Feb 10, 2011 11:23 AMHi. I am still trying to sort out a problem with the Eclipse infocenter web application running on jboss-eap-4.2. I first encountered this problem a long time ago and posted about it (http://community.jboss.org/message/199407#199407). I was able to work around the problem then but now I have to confront it.
My web application is packaged as a WAR file. It includes an older version of Apache commons-logging. When I try to open the main JSP, the application fails with the following error:
*************
2011-02-10 10:48:37,343 ERROR [org.apache.catalina.core.ContainerBase] Servlet.service() for servlet equinoxbridgeservlet threw exception
org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@1677979 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@1677979 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
*************
I can solve this problem by putting the latest log4j JAR file at this path: jboss-eap-4.2/jboss-as/lib/endorsed/log4j-1.2.16.jar. I can't use this solution because of the other applications running on the same server.
I've been given advice about packaging log4j and isolating it in my WAR file before (
http://community.jboss.org/message/199239#199239). I think I have the WAR packaged correctly but I still see the same problem. My WAR file contains this jboss-web.xml file:
************
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>com.example:loader=my-documentation.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
*************
I put log4j-1.2.16.jar in the WAR file at WEB-INF/lib/log4j-1.2.16.jar.
Do I need to include a log4j configuration file? Am I isolating the log4j class loading properly?
Thanks for your help.
Peter