Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

slf4j error on Grails 1.3.7 #39

Closed
eliotsykes opened this Issue · 2 comments

2 participants

@eliotsykes

Running a test using betamax on Grails 1.3.7 causes the following error:

org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:591)
    at org.eclipse.jetty.util.log.JettyAwareLogger.debug(JettyAwareLogger.java:193)
    at org.eclipse.jetty.util.log.Slf4jLog.debug(Slf4jLog.java:92)
    at org.eclipse.jetty.util.log.Log.initialized(Log.java:80)
    at org.eclipse.jetty.util.log.Log.getLogger(Log.java:357)
    at org.eclipse.jetty.util.log.Log.getLogger(Log.java:347)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.<clinit>(AbstractLifeCycle.java:28)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at betamax.proxy.jetty.ProxyServer.class$(ProxyServer.groovy)
    at betamax.proxy.jetty.ProxyServer.$get$$class$betamax$proxy$jetty$ProxyHandler(ProxyServer.groovy)
    at betamax.proxy.jetty.ProxyServer.start(ProxyServer.groovy:30)
    at betamax.proxy.jetty.ProxyServer$start.call(Unknown Source)
    at betamax.Recorder.startProxy(Recorder.groovy:166)
    at betamax.Recorder.this$2$startProxy(Recorder.groovy)
    at betamax.Recorder$this$2$startProxy.callCurrent(Unknown Source)
    at betamax.Recorder.withTape(Recorder.groovy:139)
    at betamax.Recorder.this$dist$invoke$2(Recorder.groovy)
    at betamax.Recorder$1.methodMissing(Recorder.groovy)
    at betamax.Recorder$1.evaluate(Recorder.groovy:152)
    at betamax.Recorder$1$evaluate.call(Unknown Source)

Rob as you found out, seems to be fixed by changing application.properties from

plugins.jetty=1.2-SNAPSHOT

to

plugins.jetty7=0.3.2

and excluding jetty-server in BuildConfig.groovy:

test("com.github.robfletcher:betamax:1.0") {
  excludes "jetty-server"
}
@robfletcher robfletcher was assigned
@robfletcher
Owner

The version of Jetty that Betamax includes has a nasty silent dependency on slf4j 1.6.x. If slf4j is present on the classpath at all it must be 1.6.x or the exception you're seeing will occur. Grails 1.3.7 includes slf4j 1.5.8 so this causes a conflict. To resolve it you need to add the following to grails-app/conf/BuildConfig.groovy:

inherits("global") {
    excludes "slf4j-api", "slf4j-log4j12", "jul-to-slf4j", "jcl-over-slf4j"
}

dependencies {
    def slf4jVersion = "1.6.2"
    compile "org.slf4j:slf4j-api:$slf4jVersion"
    runtime "org.slf4j:slf4j-log4j12:$slf4jVersion", "org.slf4j:jul-to-slf4j:$slf4jVersion", "org.slf4j:jcl-over-slf4j:$slf4jVersion"
}

I could potentially fix this by downgrading the version of Jetty Betamax depends on. I'll need to test with Grails 2.0 to ensure the same problem doesn't occur in reverse

@robfletcher robfletcher referenced this issue from a commit
Rob Fletcher #39: change example grails app to use 1.3.7 51f00a4
@robfletcher robfletcher referenced this issue from a commit
Rob Fletcher #39: force use of slf4j 1.6.2 1217a32
@robfletcher
Owner

Hmm wait. Looks like that workaround will get you through a unit test but grails run-app barfs with:

org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [HibernateGrailsPlugin]!
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

slf4j really is horrible.

@robfletcher robfletcher closed this issue from a commit
Rob Fletcher Reduce jetty-server dependency to prevent slf4j clashes. Use java.uti…
…l.logging instead of log4j. Fixes #39
77b849f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.