Description
I have an application that uses both amazon-kinesis-client and couchbase java-client. I ran into an issue where a class is on the classpath multiple times. This results in a method not found exception.
Caused by: java.lang.NoSuchMethodError: 'io.netty.channel.DefaultChannelId io.netty.channel.DefaultChannelId.newInstance()' at io.netty.channel.AbstractChannel.newId(AbstractChannel.java:113) at io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:73) at io.netty.bootstrap.FailedChannel.<init>(FailedChannel.java:33) at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:320) at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:155) at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:116) at io.netty.channel.pool.SimpleChannelPool.connectChannel(SimpleChannelPool.java:267) at io.netty.channel.pool.SimpleChannelPool.acquireHealthyFromPoolOrNew(SimpleChannelPool.java:177) at io.netty.channel.pool.SimpleChannelPool.acquire(SimpleChannelPool.java:162) at io.netty.channel.pool.SimpleChannelPool.acquire(SimpleChannelPool.java:157) at software.amazon.awssdk.http.nio.netty.internal.HonorCloseOnReleaseChannelPool.acquire(HonorCloseOnReleaseChannelPool.java:45) |
What I found is there are three libraries that have embedded this class. Each embed a different version of netty.
This creates a problem which is very difficult to trace and explain to other developers. There is also no really good solution without directly manipulating the classpath to put couchbase last (which may or may not work). I can't resolve any conflicts with netty at all using maven. Using a shaded jar is essential creating all of the problems maven was designed to fix with classpath resolution.
What I propose is instead of creating a shaded jar for core-io create a normal jar with dependencies and allow developers to deal with conflicts using maven.