Forums de discussion

java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be ca

tony kerz, modifié il y a 13 années.

java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be ca

New Member Publications: 5 Date d'inscription: 07/03/11 Publications récentes
anyone ever see this:



03:27:31,125 INFO  [HookHotDeployListener:394] Registering hook for liferay-custom-hook
log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
	at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:238)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
	at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
	at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471)
	at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
	at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821)
	at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.initLogger(HookHotDeployListener.java:1105)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:401)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
	at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
	at java.lang.Thread.run(Thread.java:619)
log4j:ERROR Could not parse url [jar:file:/F:/product/liferay/liferay-portal-6.0.6/tomcat-6.0.29/webapps/liferay-custom-hook/WEB-INF/lib/portal-impl.jar!/META-INF/portal-log4j.xml].
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:172)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
	at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
	at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471)
	at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
	at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821)
	at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.initLogger(HookHotDeployListener.java:1105)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:401)
	at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
	at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
	at java.lang.Thread.run(Thread.java:619)



i got it with 6.0.5 and currently with 6.0.6.

i didn't do anything fancy with a "hook" project i'm working on (e.g. add a log4j jar or anything). i have a liferay-plugin-package.properties that looks like:


name=Liferay Custom
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL
portal-dependency-jars=\
    portal-impl.jar,\
    easyconf.jar,\
    commons-lang.jar,\
    commons-digester.jar,\
    commons-configuration.jar,\
    xstream.jar,\
    commons-collections.jar,\
    commons-beanutils.jar
thumbnail
Thiago Leão Moreira, modifié il y a 13 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Liferay Legend Publications: 1449 Date d'inscription: 10/10/07 Publications récentes
Hey Tony,

I noticed that you added portal-impl.jar to your classpath THIS IS FORBIDDEN! Adding this jar to you plugin will make Liferay behavior not properly like the problem that you are facing.
Arsh g, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

New Member Publications: 11 Date d'inscription: 18/02/11 Publications récentes
Now i am not included portal-impl.jar then also it throws

java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
thumbnail
Hitoshi Ozawa, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
Have you tried Googling this exception?
Check if you have any log4j settings in the WEB-INF\classes folder.
thumbnail
Thiago Leão Moreira, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Liferay Legend Publications: 1449 Date d'inscription: 10/10/07 Publications récentes
Hey Tony,

This seems that you have two instances of log4j available in different classpaths. Probably one in the Global classpath and another in the Application classpath.
thumbnail
Hitoshi Ozawa, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
When doing a Liferay .war install, I think some application server may already have log4j in it's path. The one in the portlet's WEB-INF is usually the org.apache.log4j.ConsoleAppender
JoseManuel Garcia, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

New Member Publications: 8 Date d'inscription: 09/05/11 Publications récentes
Hi Tony Kerz,

I have the same problem that you. For one hand I have this error: log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender.

And the other hand I have this problem: log4j:ERROR Could not parse url [jar:file:/C:/Liferay/liferay-portal-6.0.6/tomcat-6.0.29/webapps/UsuariosConectados-portlet/WEB-INF/lib/portal-impl.jar!/META-INF/portal-log4j.xml].
java.lang.NullPointerException.

Have you find solution for this problem?
thumbnail
Bartlomiej Knabel, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Junior Member Publications: 76 Date d'inscription: 30/01/11 Publications récentes
I have simmilar problem as JoseManuel - did You solve it?
thumbnail
Gaurang Sheladia, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Regular Member Publications: 159 Date d'inscription: 15/02/09 Publications récentes
Hi All,

I am using Liferay 6.0.5 and i have migrated Struts Plugin portlet from Liferay 5.2.3 to 6.0.5 but still i am getting same error


log4j:ERROR Could not parse url [jar:file:/C:/Liferay/liferay-portal-6.0.6/tomcat-6.0.29/webapps/UsuariosConectados-portlet/WEB-INF/lib/portal-impl.jar!/META-INF/portal-log4j.xml].
java.lang.NullPointerException.


Does any one find any alternative solution?

Thanks in advance.

-- Gaurang
thumbnail
Thiago Leão Moreira, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Liferay Legend Publications: 1449 Date d'inscription: 10/10/07 Publications récentes
Hey Gaurang,

The problem is that you have the portal-impl.jar on your portlet classpath. portal-impl.jar contains the core classes of Liferay and never should be referenced directly by portlet. It is explicit forbidden add this jar to your portlet's classpath. Unknown problems can be raised like the one that you are facing.
thumbnail
Gaurang Sheladia, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Regular Member Publications: 159 Date d'inscription: 15/02/09 Publications récentes
Yes Thiago, you are right. I have resolved that issue.

Thanks again for your response.
thumbnail
Vincent Paranpan, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

New Member Publications: 17 Date d'inscription: 14/10/10 Publications récentes
Thiago Leão Moreira:
Hey Gaurang,

The problem is that you have the portal-impl.jar on your portlet classpath. portal-impl.jar contains the core classes of Liferay and never should be referenced directly by portlet. It is explicit forbidden add this jar to your portlet's classpath. Unknown problems can be raised like the one that you are facing.



Hi Thiago,

I have the same problem, I wanted to copy the functionality of LogoutAction class in my customized hook plugin project, so I've used a part of Liferay's LogoutAction code in one of my classes, but whenever I tried deploying the hook plugin it gives me an error:

java.lang.NoClassDefFoundError: com/liferay/portal/util/PropsValues


Since the class exists inside the portal-impl.jar I included the jar to my references, but once I redeployed my hook plugin I encountered the error discussed in this thread..

ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
.
.
.
ERROR Could not parse url [jar:file:/C:/Liferay/liferay-portal-6.0.5/tomcat-6.0.26/webapps/my-test-hook/WEB-INF/lib/portal-impl.jar!/META-INF/portal-log4j.xml].
java.lang.NullPointerException


Would you have any advice on what I should do?

Cheers,
Vincent
Hector Leon Garay, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

New Member Publications: 9 Date d'inscription: 14/07/11 Publications récentes
Hi Vincet,

Did you find the solution for your problem? I have the same issue as you have with a hook.

If you have any solution, can you please share it?

Regards.

HLG
Dianne Civil, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

New Member Publications: 3 Date d'inscription: 24/03/10 Publications récentes
Did anyone find a solution for this ?

Dianne
thumbnail
Gaurang Sheladia, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Regular Member Publications: 159 Date d'inscription: 15/02/09 Publications récentes
Hi Dianne,

The problem is that you have the portal-impl.jar on your portlet classpath. portal-impl.jar contains the core classes of Liferay and never should be referenced directly by portlet. It is explicit forbidden add this jar to your portlet's classpath. Unknown problems can be raised like the one that you are facing.
Joaquín Fernández, modifié il y a 12 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Junior Member Publications: 93 Date d'inscription: 02/01/12 Publications récentes
Hi all

I have the same error:

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:248)



Where can i configure the portlet classpath? I don't have any jar added in the portal-dependency-jars in the liferay-plugin-package.properties

thanks
thumbnail
Pedro Bezunartea López, modifié il y a 10 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Junior Member Publications: 38 Date d'inscription: 11/07/05 Publications récentes
Gaurang Sheladia:
Yes Thiago, you are right. I have resolved that issue.

Thanks again for your response.

Gaurang Sheladia:
Hi Dianne,

The problem is that you have the portal-impl.jar on your portlet classpath. portal-impl.jar contains the core classes of Liferay and never should be referenced directly by portlet. It is explicit forbidden add this jar to your portlet's classpath. Unknown problems can be raised like the one that you are facing.


From your messages it looks like you managed to solve the problem, could you please give clear instructions on how to solve the issue?

The problem several users seem to have is:
  • Create a hook to replace the action of a default portlet included in portal-impl.jar
  • Deploy the hook. The deployment throws a NoClassDefFoundError exception for the class being replaced.
  • The developer adds portal-impl.jar in "portal-dependency-jars" config parameter in the hook's configuration file "liferay-plugin-package.properties". Redeployment
  • A Log4j error is thrown on deployment:
    log4j:ERROR Could not create an Appender. Reported error follows. java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender

From your message the conclusion is that portal-impl.jar should NOT be included. That's clear but, how did you solve the original problem then?

TIA,

Pedro.
Gwowen Fu, modifié il y a 11 années.

RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b

Expert Publications: 315 Date d'inscription: 27/12/10 Publications récentes
Thiago Leão Moreira:
Hey Gaurang,

portal-impl.jar contains the core classes of Liferay and never should be referenced directly by portlet.


I need to import "com.liferay.portal.xml.QNameImpl" class that's in portal-impl.jar, if we cannot reference it directly, what's the alternative way?

Thanks!
Gwowen