0

I am new to Java and have jumped into maintaining an existing software system written in Java which makes use of Vertx.io . When I call the Vertx web client .get() method, I get an error with the netty package. I have googled for the error, but cannot find anything. Can someone suggest what I am doing wrong?

Here is the calling code:

WebClient client = WebClient.create(vertx);
client
    .get(port, server, path)
    .timeout(5000)
    .send(ar -> {
        if (ar.succeeded()) {
            ...

Here is the exception:

java.lang.NoSuchMethodError: io.netty.util.AsciiString.cached(Ljava/lang/String;)Lio/netty/util/AsciiString;
    at io.netty.handler.codec.http.HttpHeaderValues.<clinit>(HttpHeaderValues.java:28)
    at io.netty.handler.codec.http.HttpUtil.<clinit>(HttpUtil.java:41)
    at io.netty.handler.codec.http.EmptyHttpHeaders.<clinit>(EmptyHttpHeaders.java:29)
    at io.netty.handler.codec.http.HttpHeaders.<clinit>(HttpHeaders.java:49)
    at io.vertx.core.http.HttpHeaders.createOptimized(HttpHeaders.java:331)
    at io.vertx.core.http.HttpHeaders.<clinit>(HttpHeaders.java:31)
    at io.vertx.ext.web.client.impl.HttpRequestImpl.<init>(HttpRequestImpl.java:70)
    at io.vertx.ext.web.client.impl.HttpRequestImpl.<init>(HttpRequestImpl.java:54)
    at io.vertx.ext.web.client.impl.WebClientImpl.request(WebClientImpl.java:50)
    at io.vertx.ext.web.client.impl.WebClientImpl.get(WebClientImpl.java:50)
    at ... my calling class
ralfe
  • 1,412
  • 2
  • 15
  • 25
  • 1
    Is the netty library deployed in your execution environment? Is it the exact same version as the one you used to build the application? – Jim Garrison Jan 16 '18 at 08:24
  • As @JimGarrison suggests, I believe you're using an older Netty version. Check you project setup – tsegismont Jan 16 '18 at 08:59

1 Answers1

2

It turned out that the issue was caused by another Vertx library (vertx-lang-ceylon) that I had added as a dependency for use with Chime to do scheduling. The version was older than the other vertx libraries and this seemed to have introduced the issue.

To fix, I edited my build.gradle file and changed

compile 'io.vertx:vertx-lang-ceylon:3.4.1'

to

compile 'io.vertx:vertx-lang-ceylon:3.5.0'

And that solved the issue.

ralfe
  • 1,412
  • 2
  • 15
  • 25