今天搭建一个Spring MVC,在jboss上部署成功后,启动服务却报了一个错,如下:
15:22:46,196 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable.
15:22:46,196 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by
15:22:46,196 ERROR [STDERR] log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@191e0eb
] whereas object of type
15:22:46,196 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@540408].
15:22:46,231 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows.
15:22:46,231 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFileAppender cannot be cast to org.apache.log4j.Appender
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:175)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:150)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:163)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:425)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:394)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:829)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:712)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
15:22:46,231 ERROR [STDERR] at org.apache.log4j.Logger.getLogger(Logger.java:104)
15:22:46,236 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:22:46,236 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
15:22:46,236 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
15:22:46,236 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
15:22:46,236 ERROR [STDERR] at org.apache.commons.logging.impl.Log4jProxy.<init>(Log4jProxy.java:132)
15:22:46,236 ERROR [STDERR] at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:39)
我用的jboss版本是4.0.5GA,解决的办法是将项目中的log4j.jar包移除即可成功启动jboss服务。