在启动jboss的时候,发现error错误,如下:
16:16:41,884 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
16:16:41,884 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
16:16:41,884 ERROR [STDERR] log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@8aa2d
] whereas object of type
而相同的项目在tomcat下面是不会报错的,查明原因后发现,原来jboss自己带了日志功能,而建立web项目的时候它自己本身也带着日志功能(你的项目中应该有spring),造成冲突。
解决办法:
修改jboss-service.xml
1)
<mbean code="org.jboss.logging.Log4jService" name="jboss.system:type=Log4jService,service=Logging">
<attribute name="ConfigurationURL">resource:log4j.xml</attribute>
<attribute name="CatchSystemOut">false</attribute>
<attribute name="Log4jQuietMode">true</attribute>
</mbean>
2)
<attribute name="Java2ClassLoadingCompliance">true</attribute>
<attribute name="UseJBossWebLoader">true</attribute>