Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be ca tony kerz March 7, 2011 7:36 PM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Thiago Leão Moreira March 9, 2011 2:28 PM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Arsh g April 30, 2011 3:09 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Hitoshi Ozawa April 30, 2011 5:08 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Thiago Leão Moreira April 30, 2011 5:37 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Hitoshi Ozawa April 30, 2011 6:52 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b JoseManuel Garcia May 27, 2011 12:32 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Bartlomiej Knabel June 7, 2011 3:11 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Gaurang Sheladia June 15, 2011 5:15 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Thiago Leão Moreira June 15, 2011 10:14 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Gaurang Sheladia August 3, 2011 2:41 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Vince P September 11, 2011 6:33 PM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Hector Leon Garay November 16, 2011 11:36 AM
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b Gwowen Fu December 26, 2012 10:33 AM
tony kerz
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be ca
March 7, 2011 7:36 PM
Answer

tony kerz

Rank: New Member

Posts: 5

Join Date: March 6, 2011

Recent Posts

anyone ever see this:


 1
 203:27:31,125 INFO  [HookHotDeployListener:394] Registering hook for liferay-custom-hook
 3log4j:ERROR Could not create an Appender. Reported error follows.
 4java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
 5    at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:238)
 6    at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171)
 7    at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
 8    at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
 9    at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471)
10    at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921)
11    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
12    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
13    at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821)
14    at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48)
15    at com.liferay.portal.deploy.hot.HookHotDeployListener.initLogger(HookHotDeployListener.java:1105)
16    at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:401)
17    at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
18    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
19    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
20    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
21    at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
22    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
23    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
24    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
25    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
26    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
27    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
28    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
29    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
30    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
31    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
32    at java.lang.Thread.run(Thread.java:619)
33log4j: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].
34java.lang.NullPointerException
35    at java.util.Hashtable.put(Hashtable.java:394)
36    at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:172)
37    at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
38    at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
39    at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471)
40    at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921)
41    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
42    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
43    at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821)
44    at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:48)
45    at com.liferay.portal.deploy.hot.HookHotDeployListener.initLogger(HookHotDeployListener.java:1105)
46    at com.liferay.portal.deploy.hot.HookHotDeployListener.doInvokeDeploy(HookHotDeployListener.java:401)
47    at com.liferay.portal.deploy.hot.HookHotDeployListener.invokeDeploy(HookHotDeployListener.java:218)
48    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:109)
49    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:182)
50    at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:38)
51    at com.liferay.portal.kernel.servlet.HookContextListener.contextInitialized(HookContextListener.java:36)
52    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
53    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
54    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1244)
55    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
56    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
57    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
58    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
59    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
60    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
61    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
62    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:

 1
 2name=Liferay Custom
 3module-group-id=liferay
 4module-incremental-version=1
 5tags=
 6short-description=
 7change-log=
 8page-url=http://www.liferay.com
 9author=Liferay, Inc.
10licenses=LGPL
11portal-dependency-jars=\
12    portal-impl.jar,\
13    easyconf.jar,\
14    commons-lang.jar,\
15    commons-digester.jar,\
16    commons-configuration.jar,\
17    xstream.jar,\
18    commons-collections.jar,\
19    commons-beanutils.jar
Thiago Leão Moreira
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
March 9, 2011 2:28 PM
Answer

Thiago Leão Moreira

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1433

Join Date: October 10, 2007

Recent Posts

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
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
April 30, 2011 3:09 AM
Answer

Arsh g

Rank: New Member

Posts: 11

Join Date: February 18, 2011

Recent Posts

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
Hitoshi Ozawa
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
April 30, 2011 5:08 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Have you tried Googling this exception?
Check if you have any log4j settings in the WEB-INF\classes folder.
Thiago Leão Moreira
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
April 30, 2011 5:37 AM
Answer

Thiago Leão Moreira

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1433

Join Date: October 10, 2007

Recent Posts

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.
Hitoshi Ozawa
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
April 30, 2011 6:52 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
May 27, 2011 12:32 AM
Answer

JoseManuel Garcia

Rank: New Member

Posts: 8

Join Date: May 9, 2011

Recent Posts

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?
Bartlomiej Knabel
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
June 7, 2011 3:11 AM
Answer

Bartlomiej Knabel

Rank: Junior Member

Posts: 59

Join Date: January 30, 2011

Recent Posts

I have simmilar problem as JoseManuel - did You solve it?
Gaurang Sheladia
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
June 15, 2011 5:15 AM
Answer

Gaurang Sheladia

Rank: Regular Member

Posts: 160

Join Date: February 15, 2009

Recent Posts

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
Thiago Leão Moreira
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
June 15, 2011 10:14 AM
Answer

Thiago Leão Moreira

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1433

Join Date: October 10, 2007

Recent Posts

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.
Gaurang Sheladia
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
August 3, 2011 2:41 AM
Answer

Gaurang Sheladia

Rank: Regular Member

Posts: 160

Join Date: February 15, 2009

Recent Posts

Yes Thiago, you are right. I have resolved that issue.

Thanks again for your response.
Vince P
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
September 11, 2011 6:33 PM
Answer

Vince P

Rank: New Member

Posts: 17

Join Date: October 13, 2010

Recent Posts

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:

1java.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..

1ERROR Could not create an Appender. Reported error follows.
2java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
3.
4.
5.
6ERROR 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].
7java.lang.NullPointerException


Would you have any advice on what I should do?

Cheers,
Vincent
Hector Leon Garay
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
November 16, 2011 11:36 AM
Answer

Hector Leon Garay

Rank: New Member

Posts: 15

Join Date: July 14, 2011

Recent Posts

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
Gaurang Sheladia
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
January 12, 2012 3:27 AM
Answer

Gaurang Sheladia

Rank: Regular Member

Posts: 160

Join Date: February 15, 2009

Recent Posts

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
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
February 8, 2012 6:43 AM
Answer

Joaquín Fernández

Rank: Junior Member

Posts: 93

Join Date: January 2, 2012

Recent Posts

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
Gwowen Fu
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
December 26, 2012 10:33 AM
Answer

Gwowen Fu

Rank: Expert

Posts: 315

Join Date: December 27, 2010

Recent Posts

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
Pedro Bezunartea López
RE: java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot b
April 4, 2014 8:00 AM
Answer

Pedro Bezunartea López

Rank: Junior Member

Posts: 38

Join Date: July 10, 2005

Recent Posts

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:
  1. Create a hook to replace the action of a default portlet included in portal-impl.jar
  2. Deploy the hook. The deployment throws a NoClassDefFoundError exception for the class being replaced.
  3. The developer adds portal-impl.jar in "portal-dependency-jars" config parameter in the hook's configuration file "liferay-plugin-package.properties". Redeployment
  4. A Log4j error is thrown on deployment:
    1log4j: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.