Jboss 中Log4冲突解决方法

问题描述:

 

你可以看到类似于下面的异常信息:

20:05:44,757 ERROR STDERR log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable. 20:05:44,757 ERROR STDERR log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by 20:05:44,757 ERROR STDERR log4j:ERROR [WebappClassLoaderDelegateFalseRepositories/WEBINF/Classes/ParentClassloaderjava.net.FactoryURLClassLoader31c43f|WebappClassLoader   delegate: false   repositories:     /WEB-INF/classes/ -

> Parent Classloader: java.net.FactoryURLClassLoader@31c43f ] whereas object of type 20:05:44,757 ERROR STDERR log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by Org.jboss.system.server.NoAnnotationURLClassLoaderab95e6. 20:05:44,820 ERROR STDERR log4j:ERROR Could not create an Appender. Reported error follows.

 

解决方案:

 

这类异常信息出现的原因为:JBoss中的发布的Application自身包含log4j和相关的commons-logging组建在它的发布包中。

JBoss的lib目录下,本身包含有这些jars包,这导致了以上jar包冲突的发生。

 

删除你自己application中的log4j和commons-logging可以解决这个问题。

 

—————————————————————————————————————————————————————————

Problem:

 

You see exceptions similar to:

 

 

 

20:05:44,757 ERROR STDERR log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable. 20:05:44,757 ERROR STDERR log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by 20:05:44,757 ERROR STDERR log4j:ERROR [WebappClassLoaderDelegateFalseRepositories/WEBINF/Classes/ParentClassloaderjava.net.FactoryURLClassLoader31c43f|WebappClassLoader   delegate: false   repositories:     /WEB-INF/classes/ -

 

 

Solution:

 

These sort of exceptions occur if an application deployed on JBoss packages log4j and commons-logging related jars in its package. JBoss has its own versions of these jars in its lib folder which results in these conflicts.

 

Removing the log4j and commons-logging jars from your application's package will solve this issue.

 

> Parent Classloader: java.net.FactoryURLClassLoader@31c43f ] whereas object of type 20:05:44,757 ERROR STDERR log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by Org.jboss.system.server.NoAnnotationURLClassLoaderab95e6. 20:05:44,820 ERROR STDERR log4j:ERROR Could not create an Appender. Reported error follows.

你可能感兴趣的:(spring)