使用java.lang.NoSuchMethodError的Logback + Janino + Resin问题

时间:2013-03-26 17:46:04

标签: logging slf4j logback resin janino

您好我使用以下版本的logback和Janino:

  <dependency org="ch.qos.logback" name="logback-core" rev="1.0.11" conf="runtime"/>
  <dependency org="ch.qos.logback" name="logback-classic" rev="1.0.11" conf="runtime"/>
  <dependency org="org.codehaus.janino" name="janino" rev="2.6.1" conf="runtime"/> 

使用<if>条件记录配置是:

<root level="INFO">
    <if condition='property("xxx").contains("dev")'>
      <then>
        <appender-ref ref="dev" />
      </then>
    </if>
</root> 

我看到的错误如下:

7:38:54,729 | -INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - 将ROOT记录器的级别设置为INFO 无法实例化[ch.qos.logback.classic.LoggerContext] 报告的例外情况: java.lang.NoSuchMethodError:org.codehaus.janino.ClassBodyEvaluator.setImplementedInterfaces([Ljava / lang / Class;)V     在ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilder.build(PropertyEvalScriptBuilder.java:48)     在ch.qos.logback.core.joran.conditional.IfAction.begin(IfAction.java:67)     在ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)     在ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)     在ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)     在ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)     在ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157)     在ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)     在ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)     在ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)     at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)     在ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)     在org.slf4j.impl.StaticLoggerBinder.init(staticLoggerBinder.java:85)     在org.slf4j.impl.StaticLoggerBinder。(StaticLoggerBinder.java:55)     在org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)     在org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)     在org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)     在org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)

为什么会抛出这个错误?

2 个答案:

答案 0 :(得分:4)

setImplementedInterfaces(Class[])方法是janino 2.6.1中ClassBodyEvaluator类的一部分。检查您的类路径,看看是否有一个不同版本的Janino潜伏在某个地方。您的类路径很可能包含不同版本的Janino。

答案 1 :(得分:1)

还应注意他们将组ID从 janino 更改为 org.codehasu.janino ,因此您需要更新的不仅仅是版本。

```
<dependency>
    <groupId>org.codehaus.janino</groupId>
    <artifactId>janino</artifactId>
    <version>2.7.8</version>
</dependency>
```