File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "log4j - ear file - jboss6" Watch "log4j - ear file - jboss6" New topic
Author

log4j - ear file - jboss6

Yaron Rel
Greenhorn

Joined: Aug 04, 2009
Posts: 20
Hi,
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:

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

here is my pom dependency of pom.xml:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>

here is my log4j.properties:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

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
Greenhorn

Joined: Aug 04, 2009
Posts: 20
Thank you very mutch :-)
Its working.
 
jQuery in Action, 2nd edition
 
subject: log4j - ear file - jboss6
 
Similar Threads
Could not resolve dependencies
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.
JSF 2 - Problem with ManagedBean
Maven / Tomcat issue with Servlet jar
Unable to create one single jar file in maven with dependencies included inside