Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

slf4j error on Grails 1.3.7 #39

Closed
eliotsykes opened this Issue Oct 12, 2011 · 2 comments

Comments

Projects
None yet
2 participants

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 Oct 12, 2011

Collaborator

robfletcher commented Oct 12, 2011

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 pushed a commit that referenced this issue Oct 12, 2011

Rob Fletcher #39: change example grails app to use 1.3.7 51f00a4

@robfletcher robfletcher pushed a commit that referenced this issue Oct 12, 2011

Rob Fletcher #39: refactored grails test into a service test b2c12e5

@robfletcher robfletcher pushed a commit that referenced this issue Oct 12, 2011

Rob Fletcher #39: force use of slf4j 1.6.2 1217a32
Collaborator

robfletcher commented Oct 12, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment