This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes log4j - ear file - jboss6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "log4j - ear file - jboss6" Watch "log4j - ear file - jboss6" New topic

log4j - ear file - jboss6

Yaron Rel

Joined: Aug 04, 2009
Posts: 20
It seams that whatever i do I keep getting the following error in the server.log:
Is there any normal working tutorial or example for integrating ear file with log4j in jboss?

2010-01-12 15:29:43,097 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/myapp
2010-01-12 15:29:43,472 ERROR [STDERR] (HDScanner) log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
2010-01-12 15:29:43,472 ERROR [STDERR] (HDScanner) log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by
2010-01-12 15:29:43,472 ERROR [STDERR] (HDScanner) log4j:ERROR [BaseClassLoader@1f66c87{vfszip:/C:/work/tools/jboss-6.0.0.M1/server/default/deploy/my-ear.ear/}] whereas object of type
2010-01-12 15:29:43,472 ERROR [STDERR] (HDScanner) log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [BaseClassLoader@28bf34{vfszip:/C:/work/tools/jboss-6.0.0.M1/server/default/deploy/....
2010-01-12 15:29:43,472 ERROR [STDERR] (HDScanner) log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
2010-01-12 15:29:53,168 ERROR [STDERR] (HDScanner) log4j:WARN No appenders could be found for logger (javax.servlet.ServletContextListener).
2010-01-12 15:29:53,168 ERROR [STDERR] (HDScanner) log4j:WARN Please initialize the log4j system properly.

It happens when I call from junit a remote stateless bean that has the following logger:

private static Logger logger = Logger.getLogger(MyDao.class);
usage in class:"in my dao");

here is my pom dependency of pom.xml:

here is my
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Yaron, welcome to Java Ranch!

Looks like you are packaging the log4j.jar file into your app, which results in classloader issues like the one you are seeing. Change your pom.xml to indicate that the log4j.jar is not needed to be packaged with your app (add a <scope> entry):

P.S. Please use the code tags when posting source code - makes it much easier to read.

JBoss In Action
Yaron Rel

Joined: Aug 04, 2009
Posts: 20
Thank you very mutch :-)
Its working.
I agree. Here's the link:
subject: log4j - ear file - jboss6
It's not a secret anymore!