Gradle-Groovy example works but Groovy example fails

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Gradle-Groovy example works but Groovy example fails

vastydeep
Hello -

When I run the Quick Start example using Gradle and Groovy, I get the proper "Hello World" response in a browser, but if I run the same code (using @Grab for needed libraries), the server starts but fails on the GET request with HTTP 500. The stack trace says:

[ratpack-compute-1-4] ERROR ratpack.server.internal.NettyHandlerAdapter -
java.lang.NoSuchMethodError: io.netty.handler.codec.http.FullHttpRequest.decoderResult()Lio/netty/handler/codec/DecoderResult;


ratpack.groovy:
==================================================
@Grab('io.ratpack:ratpack-groovy:0.9.19')
@Grab('org.slf4j:slf4j-simple:1.7.12')

import static ratpack.groovy.Groovy.ratpack
import org.slf4j.impl.StaticLoggerBinder

ratpack {
        serverConfig {
                port(6060)
        }
    handlers {
        get() {
            render "Hello World!"
        }
        get(":name") {
            render "Hello $pathTokens.name!"
        }
    }
}
==================================================

Gradle script:
==================================================
buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "io.ratpack:ratpack-gradle:0.9.19"
  }
}

apply plugin: "io.ratpack.ratpack-groovy"
apply plugin: "idea"

repositories {
  jcenter()
}

dependencies {
  runtime "org.slf4j:slf4j-simple:1.7.12"
}
==================================================

Am I doing something obviously wrong?

Running Java 1.8.0_51 and Groovy 2.4.3
Contact with my own species has always disappointed me. - Captain Nemo, The Mysterious Island
Reply | Threaded
Open this post in threaded view
|

Re: Gradle-Groovy example works but Groovy example fails

danveloper
Administrator
Hey groovyvergnugen! Thanks for the question!

When building Ratpack apps from a project structure that builds with Gradle, you don't need to use the @Grab annotations. Gradle will ensure the dependencies are in place. Here's a great reference for a Groovy-based Ratpack project: https://github.com/ratpack/example-ratpack-gradle-groovy-app

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Gradle-Groovy example works but Groovy example fails

vastydeep
Thanks for the reply, Danveloper. I don't have the @Grab annotations in the Gradle version of the Groovy script; otherwise it is identical:

import static ratpack.groovy.Groovy.ratpack
import org.slf4j.impl.StaticLoggerBinder

ratpack {
        serverConfig {
                port(6060)
        }
    handlers {
        get {
            render "Hello World!"
        }
        get(":name") {
            render "Hello $pathTokens.name!"
        }
    }
}
Contact with my own species has always disappointed me. - Captain Nemo, The Mysterious Island
Reply | Threaded
Open this post in threaded view
|

Re: Gradle-Groovy example works but Groovy example fails

danveloper
Administrator
And you're placing this file in src/ratpack/ratpack.groovy? How are you running it? "gradle run" should suffice from the command line.
Reply | Threaded
Open this post in threaded view
|

Re: Gradle-Groovy example works but Groovy example fails

vastydeep
Yes, it is in src/ratpack and I'm using "gradle run". It's the standalone Groovy version that fails.

Interestingly I found source code for  io.netty.handler.codec.http.FullHttpRequest. There is no method decoderResult() (which is what the stack trace says,) only getDecoderResult() inherited from io.netty.handler.codec.http.HttpObject.
Contact with my own species has always disappointed me. - Captain Nemo, The Mysterious Island