vert-x3 / vertx-examples

Vert.x examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

“NoSuchMethodErrors” due to multiple versions of io.netty:netty-codec:jar

Bing-ok opened this issue · comments

Issue description

Hi, there are multiple versions of io.netty:netty-codec in vertx-examples\cassandra-example. As shown in the following dependency tree, according to Maven's “nearest wins” strategy, only io.netty:netty-codec:4.0.56.Final can be loaded, and io.netty:netty-codec:4.1.48.Final will be shadowed.

However, several methods defined in shadowed version io.netty:netty-codec:4.1.48.Final are referenced by client project via io.vertx:vertx-cassandra-client:3.9.0, but missing in the actually loaded version io.netty:netty-codec:4.0.56.Final.

For instance, the following missing methods(defined in io.netty:netty-codec:4.1.48.Final) are actually referenced by vertx-examples\cassandra-example, which will introduce a runtime error(i.e., "NoSuchMethodError") into vertx-examples\cassandra-example.

1. io.netty.handler.codec.HeadersUtils: java.util.Iterator iteratorAsString(java.lang.Iterable) is invoked by vertx-examples\cassandra-example via the following path:


paths------
<io.vertx.example.cassandra.cassandra.simple.SimpleExample: void main(java.lang.String[])> vertx-examples\cassandra-examples\target\classes
<io.vertx.core.Launcher: void main(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.Object,java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void execute(java.lang.String,java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.BareCommand: void run()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.BareCommand: void run(java.lang.Runnable)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.BareCommand: io.vertx.core.Vertx startVertx()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.VertxOptions: void init (io.vertx.core.json.JsonObject)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.VertxOptionsConverter: void fromJson(java.lang.Iterable,io.vertx.core.VertxOptions)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.netty.handler.codec.http.DefaultHttpHeaders: java.util.Iterator iterator()> Repositories\io\netty\netty-codec-http\4.1.48.Final\netty-codec-http-4.1.48.Final.jar
<io.netty.handler.codec.HeadersUtils: java.util.Iterator iteratorAsString(java.lang.Iterable)>

2. io.netty.handler.codec.compression.ZlibCodecFactory: boolean isSupportingWindowSizeAndMemLevel() is invoked by vertx-examples\cassandra-example via the following path:


paths------
<io.vertx.example.cassandra.cassandra.simple.SimpleExample: void main(java.lang.String[])> vertx-examples\cassandra-examples\target\classes
<io.vertx.core.Launcher: void main(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.Object,java.lang.String[])>> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void execute(java.lang.String,java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.RunCommand: void run()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.RunCommand: void initializeRedeployment()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.Watcher: io.vertx.core.impl.launcher.commands.Watcher watch()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.http.impl.HttpClientImpl$lambda_webSocket_3__256: void handle(java.lang.Object)>
<io.vertx.core.http.impl.HttpClientImpl: void lambda$webSocket$3(io.vertx.core.http.WebSocketConnectOptions,io.vertx.core.Handler,io.vertx.core.impl.ContextInternal,io.vertx.core.AsyncResult)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.http.impl.Http1xClientConnection: void toWebSocket(java.lang.String,io.vertx.core.MultiMap,io.vertx.core.http.WebsocketVersion,java.util.List,int,io.vertx.core.Handler)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.http.impl.Http1xClientConnection: java.util.ArrayList initializeWebsocketExtensionHandshakers(io.vertx.core.http.HttpClientOptions)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.netty.handler.codec.compression.ZlibCodecFactory: boolean isSupportingWindowSizeAndMemLevel()>

3. io.netty.handler.codec.ReplayingDecoderByteBuf: io.netty.buffer.ByteBuf asReadOnly() is invoked by vertx-examples\cassandra-example via the following path:


paths------
<io.vertx.example.cassandra.cassandra.simple.SimpleExample: void main(java.lang.String[])> vertx-examples\cassandra-examples\target\classes
<io.vertx.core.Launcher: void main(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void dispatch(java.lang.Object,java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.VertxCommandLauncher: void execute(java.lang.String,java.lang.String[])> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.RunCommand: void run()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.RunCommand: void initializeRedeployment()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.impl.launcher.commands.Watcher: io.vertx.core.impl.launcher.commands.Watcher watch()> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.http.impl.VertxHttp2Stream$lambda_new_0__128: void handle(java.lang.Object)> 
<io.vertx.core.http.impl.VertxHttp2Stream: void lambda$new$0(io.vertx.core.http.impl.Http2ConnectionBase,io.netty.handler.codec.http2.Http2Stream,java.lang.Void)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.vertx.core.http.impl.VertxHttp2ConnectionHandler: void consume(io.netty.handler.codec.http2.Http2Stream,int)> Repositories\io\vertx\vertx-core\3.9.0\vertx-core-3.9.0.jar
<io.netty.handler.codec.http2.Http2ConnectionHandler: void onError(io.netty.channel.ChannelHandlerContext,boolean,java.lang.Throwable)> Repositories\io\netty\netty-codec-http2\4.1.48.Final\netty-codec-http2-4.1.48.Final.jar
<io.netty.handler.codec.http2.Http2CodecUtil: void clinit()> Repositories\io\netty\netty-codec-http2\4.1.48.Final\netty-codec-http2-4.1.48.Final.jar
<io.netty.handler.codec.ReplayingDecoderByteBuf: io.netty.buffer.ByteBuf asReadOnly()>

Suggested fixing solutions

  1. Use configuration attribute <dependencyManagement> to unify the version of library io.netty:netty-codec to be 4.1.48.Final in vertx-examples\cassandra-example's pom file.
  2. Upgrade dependency io.vertx:vertx-cassandra-client from 3.9.0 to 4.0.0.Beta1. Because the newer version io.vertx:vertx-cassandra-client:4.0.0.Beta1 does not invoke the above missing methods, such upgrading can solve the problem.
  3. Declare a direct dependency io.netty:netty-codec:4.1.48.Final in the pom file of vertx-examples\cassandra-example to upgrade version from 4.0.56.Final to 4.1.48.Final.

Please let me know which solution do you prefer? I can submit a PR to fix it.

Thank you very much for your attention.
Best regards,

Dependency tree----


[INFO] io.vertx:cassandra-examples:jar:3.9.0
[INFO] +- io.vertx:vertx-cassandra-client:jar:3.9.0:compile
[INFO] |  +- com.datastax.cassandra:cassandra-driver-core:jar:3.5.0:compile
[INFO] |  |  +- io.netty:netty-handler:jar:4.0.56.Final:compile
[INFO] |  |  |  +- (io.netty:netty-buffer:jar:4.0.56.Final:compile - omitted for conflict with 4.1.48.Final)
[INFO] |  |  |  +- (io.netty:netty-transport:jar:4.0.56.Final:compile - omitted for conflict with 4.1.48.Final)
[INFO] |  |  |  \- io.netty:netty-codec:jar:4.0.56.Final:compile
[INFO] |  |  |     \- (io.netty:netty-transport:jar:4.0.56.Final:compile - omitted for duplicate)
[INFO] |  |  +- io.dropwizard.metrics:metrics-core:jar:3.2.2:compile
[INFO] |  |  +- com.github.jnr:jnr-ffi:jar:2.1.7:compile
[INFO] |  |  |  +- com.github.jnr:jffi:jar:1.2.16:compile
[INFO] |  |  |  +- com.github.jnr:jffi:jar:native:1.2.16:runtime
[INFO] |  |  |  +- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] |  |  |  +- org.ow2.asm:asm-commons:jar:5.0.3:compile
[INFO] |  |  |  |  \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate)
[INFO] |  |  |  +- org.ow2.asm:asm-analysis:jar:5.0.3:compile
[INFO] |  |  |  |  \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate)
[INFO] |  |  |  +- org.ow2.asm:asm-tree:jar:5.0.3:compile
[INFO] |  |  |  |  \- (org.ow2.asm:asm:jar:5.0.3:compile - omitted for duplicate)
[INFO] |  |  |  +- org.ow2.asm:asm-util:jar:5.0.3:compile
[INFO] |  |  |  |  \- (org.ow2.asm:asm-tree:jar:5.0.3:compile - omitted for duplicate)
[INFO] |  |  |  \- com.github.jnr:jnr-x86asm:jar:1.0.2:compile
[INFO] |  |  \- com.github.jnr:jnr-posix:jar:3.0.44:compile
[INFO] |  |     +- (com.github.jnr:jnr-ffi:jar:2.1.7:compile - omitted for duplicate)
[INFO] |  |     \- com.github.jnr:jnr-constants:jar:0.9.9:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  +- com.google.guava:guava:jar:25.1-jre:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  |  +- org.checkerframework:checker-qual:jar:2.0.0:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO] |  |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] |  |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] |  \- io.vertx:vertx-core:jar:3.9.0:compile
[INFO] |     +- io.netty:netty-common:jar:4.1.48.Final:compile
[INFO] |     +- io.netty:netty-buffer:jar:4.1.48.Final:compile
[INFO] |     |  \- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     +- io.netty:netty-transport:jar:4.1.48.Final:compile
[INFO] |     |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  \- (io.netty:netty-resolver:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     +- (io.netty:netty-handler:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     +- io.netty:netty-handler-proxy:jar:4.1.48.Final:compile
[INFO] |     |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  +- io.netty:netty-codec-socks:jar:4.1.48.Final:compile
[INFO] |     |  |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  |  +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  |  \- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  \- (io.netty:netty-codec-http:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     +- io.netty:netty-codec-http:jar:4.1.48.Final:compile
[INFO] |     |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  \- (io.netty:netty-handler:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     +- io.netty:netty-codec-http2:jar:4.1.48.Final:compile
[INFO] |     |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  +- (io.netty:netty-handler:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  \- (io.netty:netty-codec-http:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     +- io.netty:netty-resolver:jar:4.1.48.Final:compile
[INFO] |     |  \- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     +- io.netty:netty-resolver-dns:jar:4.1.48.Final:compile
[INFO] |     |  +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-resolver:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |  +- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     |  \- io.netty:netty-codec-dns:jar:4.1.48.Final:compile
[INFO] |     |     +- (io.netty:netty-common:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |     +- (io.netty:netty-buffer:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |     +- (io.netty:netty-transport:jar:4.1.48.Final:compile - omitted for duplicate)
[INFO] |     |     \- (io.netty:netty-codec:jar:4.1.48.Final:compile - omitted for conflict with 4.0.56.Final)
[INFO] |     +- com.fasterxml.jackson.core:jackson-core:jar:2.10.2:compile
[INFO] |     \- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile
[INFO] |        +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.2:compile
[INFO] |        \- (com.fasterxml.jackson.core:jackson-core:jar:2.10.2:compile - omitted for duplicate)
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.25:compile
[INFO]    \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for conflict with 1.7.21)

@vietj Could you please help me review this issue? Thank you very much.

@Bing-ok I fail to reproduce.

I checked out the 3.x branch and ran the examples in an IDE => OK

Then I installed the CLI (it seems you start the examples from the CLI). As vertx-cassandra-client is not included by default, I added this to the stack file:

{
      "groupId": "io.vertx",
      "artifactId": "vertx-cassandra-client",
      "version": "${vertx.version}",
      "included": true
}

Ran vertx resolve --dir=lib vertx-stack.json in the CLI root directory to update the stack.

Ran vertx run src/main/java/io/vertx/example/cassandra/simple/SimpleExample.java in cassandra-client directory => OK

Can you please provide details about your setup?

I see that the project has upgraded io.vertx:vertx-cassandra-client from 3.9.0 to 4.0.0, , so io.netty:netty-codec version conflict is resolved. Thanks for your support!