The deploy process added log4j.jar at /lib for any plugins

Description

The deploy process added log4j.jar for any plugins. This will cause errors in tomcat like following.

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1ac1fe4
] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1ac1fe4
].
log4j:ERROR Could not instantiate appender named "CONSOLE".

How to fix it? change the deployment process.

Environment

6.0, at revision: 51611

Activity

Show:

Massimiliano Assante May 4, 2012 at 7:56 AM

I Can confirm that Adding system property -Dlog4j.ignoreTCL=true and adding log4j and commons-logging to WEB-INF/lib folder of the app war file solved the problem on LR 6.0.6 CE

Tahura June 17, 2011 at 10:13 AM

Adding system property -Dlog4j.ignoreTCL=true and adding log4j and commons-logging to WEB-INF/lib folder of the app war file seemed to do the trick. I no longer see class x is not assignable to class y type errors and also, my app log files are correctly generated.

Tahura June 16, 2011 at 11:47 AM

Just so that you are clear, my problem is intermittent, sort of.

When I have a clean Glassfish/Liferay without my web application portlet, everything seems to be fine. Then I drop my portlet web application under Glassfish/deploy folder and it gets auto deployed. Logging works fine and my app log files are correctly generated. Now when I stop and start glassfish a number of times (anywhere between 1 to 5), at some point in time, logging fails. The message that I see in glassfish's server.log file is:

[#|2011-06-16T13:49:25.071-0400|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=pool-1-thread-1;_RequestID=a8bc2c92-236d-4108-93da-1179908be7e2;|log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.|#]

[#|2011-06-16T13:49:25.077-0400|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=pool-1-thread-1;_RequestID=a8bc2c92-236d-4108-93da-1179908be7e2;|
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by |#]

[#|2011-06-16T13:49:25.077-0400|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=pool-1-thread-1;_RequestID=a8bc2c92-236d-4108-93da-1179908be7e2;|
log4j:ERROR [WebappClassLoader
delegate: true
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> java.net.URLClassLoader@cb42cf

] whereas object of type |#]

After this error appears, no matter how many times I restart Glassfish, the error always shows up at start up. Also, my web app's log files are no longer generated! The only workaround that works for me is to undeploy my web app, clean up glassfish directories, restart glassfish and redeploy my web app.

As you can imagine, this is not much of a workaround since doing this in production env, (power failure, system reboot, etc) will be extremely painful.

My web application contains a log4j.properties file in the WEB-INF/classes folder. Neither log4j or commons-logging are packaged in the WEB-INF/lib directory. When my web app gets deployed, I can see that LifeRay does indeed add those jars files to the web apps's lib directory. If I try to delete these jars and restart glassfish, I get a NoClassDefFoundError

ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for my-portlet
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for my-portlet
at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:45)
....
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

I'm trying to understand what kinda fix I can expect with Liferay 6.0 EE or 6.1 CE.

My env is:
Glassfish server 3.1
Liferay 6.0.5
Windows 7

Our web app which is soon to be deployed to production will run on Unix platform.

Thanks for your help.

Tahura June 16, 2011 at 9:56 AM

Thanks.

Have there been other changes included in the EE or CE to fix this issue?

I don't see how simply not adding the log4j and commons-logging jar files to my web app's WEB-INF/lib folder will fix this issue. As I previously stated, when those jars are not present and I start my Glassfish server, I see a NoClassDefFoundError.

MikaM June 16, 2011 at 9:50 AM

This was fixed for 6.0 Enterprise Edition and upcoming 6.1 Community Edition.

Fixed

Details

Assignee

Reporter

Liferay Contributor's Agreement

Accept

Components

Priority

Zendesk Support

Created May 3, 2010 at 11:47 AM
Updated June 23, 2023 at 8:54 PM
Resolved June 16, 2011 at 5:32 PM
Loading...