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.
How to fix it?
when a plugin got hot deployed in LR, the following three files are added:
$
{tomcat.as}\webapps\solr-web\WEB-INF\classes\log4j.properties${tomcat.as}
\webapps\solr-web\WEB-INF\classes\logging.properties
{tomcat.as}$
\webapps\solr-web\WEB-INF\lib\log4j.jar
Since the portlets and Liferay core use two different classloaders (WebappClassLoader and StandardClassLoader) and that is why you saw the error message.
To fix this one temporarily, delete the above files from plugin after it is deployed, clean the cache, and restart Tomcat.
A better fix would be: change hot-deployment process.