由于记录错误,Struts启动失败

时间:2015-04-28 12:48:57

标签: struts2 log4j classloader slf4j nosuchmethoderror

Struts应用程序无法以log4j启动。 怎么了? 这是log4j.properties

# Direct to stdout
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

# Root logger option
log4j.rootLogger=INFO, stdout

# Good for troubleshooting
log4j.logger.org.hibernate=INFO

# Log JDBC parameters
log4j.logger.org.hibernate.type=ALL

由于日志记录错误,Struts启动失败。

INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:120)
    at com.opensymphony.xwork2.util.logging.commons.CommonsLogger.info(CommonsLogger.java:42)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:175)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
    ...

апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Struts2HiberQuize_last] startup failed due to previous errors

1 个答案:

答案 0 :(得分:1)

由于SLF4J(Simple Logging Facade for Java)的问题,而不是Log4j,您的应用程序服务器无法启动。你可能是:

  1. 包括旧版SLF4J或
  2. 混合多个版本的SLF4J(其中一个旧版本)或
  3. 应用程序服务器的共享库中有一个旧的SLF4J版本。
  4. 要解决此问题,