groovy.lang.MissingMethodException: No signature of method

89 views
Skip to first unread message

santo...@gmail.com

unread,
Mar 27, 2024, 4:13:12 PM3/27/24
to vert.x
For the first time I'm trying to use Groovy for a new Vert.x project instead of java and as usual I'm trying to work with a fat jar.

For now I'm trying to access a MySQL database, but this doesn't work as expected.

Initially I couldn't run the code because the main verticle class wasn't found since it's not added to the fat jar during the build step.
To get it working, I had to add a groovy compilation step to the build process so that the compiled Groovy code is included in the final fat jar.

Now the verticle starts fine and I can connect to the database, but when I try to run a query on the connection, with the following code:

client.getConnection { connRes ->
if (connRes.succeeded()) {
def connection = connRes.result()
println("connected")

                connection.query("SELECT * FROM demotable LIMIT 10", { res ->
                    if (res.succeeded()) {
                        println("Query succeeded")
    } else {
                        println("Query failed: ${res.cause().message}")
                    }

                    // Close the connection
                    connection.close()
                })
                startPromise.complete()
} else {
                println("Could not connect to the database: ${connRes.cause().message}")
                startPromise.fail(connRes.cause())
}
}

I get the following error:

groovy.lang.MissingMethodException: No signature of method: io.vertx.mysqlclient.impl.MySQLConnectionImpl.query() is applicable for argument types: (String, c.m.d.MainVerticle$_start_closure1$_closure2) values: [SELECT * FROM demotable LIMIT 10, com.mycompany.demo.MainVerticle$_start_closure1$_closure2@4bf67ee1]

Obviously the signature of the query() method simply expects a string, but the compilation of the groovy code apparently adds some extra closures to the call.

How can this be solved?

To be honest I'm having a hard time getting all the pieces together since the Vert.x docs for Groovy are almost non-existent.
Reply all
Reply to author
Forward
0 new messages