question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maven dependency conflicts with netty-all

See original GitHub issue

Describe the issue

I am using S3AsyncClient as below:

S3AsyncClient client = S3AsyncClient.builder()
                .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
                .endpointOverride(URI.create(configExt.getString(HOSTNAME)))
                .region(region)
                .build();

Due to maven depedency conflicts, I exclude some dependencies

             <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
                <exclusions>... more below...</exclusions>

Then I got a runtime error as below:

	 Caused by:java.lang.NoClassDefFoundError: io/netty/channel/ChannelFactory

Steps to Reproduce

When I added S3’s dependency to an existing project, which depends on

io.netty:netty-all:jar:4.0.36.Final:compile

I need to exclude some dependency as below to fix dependcy conflicts:

(the maven dependency conflict)

  Found in:
    io.netty:netty-transport:jar:4.1.61.Final:runtime
    io.netty:netty-all:jar:4.0.36.Final:compile
  Duplicate classes:...
<dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>netty-handler</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-codec-http</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-transport-native-unix-common</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-buffer</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-transport</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-codec</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-common</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty-transport-native-epoll</artifactId>
                    <groupId>io.netty</groupId>
                </exclusion>
            </exclusions>
        </dependency>

After fixing the dependency errors I got the mentioned runtime error.

Current Behavior

The call stack is below:

	Caused by: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: io/netty/channel/ChannelFactory
		at software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup.resolveChannelFactory(SdkEventLoopGroup.java:145)
		at software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup.<init>(SdkEventLoopGroup.java:79)
		at software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup.<init>(SdkEventLoopGroup.java:62)
		at software.amazon.awssdk.http.nio.netty.SdkEventLoopGroup$DefaultBuilder.build(SdkEventLoopGroup.java:207)
		at software.amazon.awssdk.http.nio.netty.internal.SharedSdkEventLoopGroup.get(SharedSdkEventLoopGroup.java:57)
		at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient$$Lambda$234/28553945.get(Unknown Source)
		at java.util.Optional.orElseGet(Optional.java:267)
		at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.eventLoopGroup(NettyNioAsyncHttpClient.java:148)
		at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.<init>(NettyNioAsyncHttpClient.java:89)
		at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient.<init>(NettyNioAsyncHttpClient.java:67)
		at software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient$DefaultBuilder.buildWithDefaults(NettyNioAsyncHttpClient.java:680)
		at software.amazon.awssdk.core.internal.http.loader.DefaultSdkAsyncHttpClientBuilder.lambda$buildWithDefaults$0(DefaultSdkAsyncHttpClientBuilder.java:43)
		at software.amazon.awssdk.core.internal.http.loader.DefaultSdkAsyncHttpClientBuilder$$Lambda$232/19846366.apply(Unknown Source)
		at java.util.Optional.map(Optional.java:215)
		at software.amazon.awssdk.core.internal.http.loader.DefaultSdkAsyncHttpClientBuilder.buildWithDefaults(DefaultSdkAsyncHttpClientBuilder.java:43)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.lambda$resolveAsyncHttpClient$8(SdkDefaultClientBuilder.java:285)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder$$Lambda$226/24154826.get(Unknown Source)
		at java.util.Optional.orElseGet(Optional.java:267)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.resolveAsyncHttpClient(SdkDefaultClientBuilder.java:285)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.finalizeAsyncConfiguration(SdkDefaultClientBuilder.java:236)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.asyncClientConfiguration(SdkDefaultClientBuilder.java:181)
		at software.amazon.awssdk.services.s3.DefaultS3AsyncClientBuilder.buildClient(DefaultS3AsyncClientBuilder.java:28)
		at software.amazon.awssdk.services.s3.DefaultS3AsyncClientBuilder.buildClient(DefaultS3AsyncClientBuilder.java:22)
		at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:129)

Your Environment

  • AWS Java SDK version used:
<dependency>
                <groupId>software.amazon.awssdk</groupId>
                <artifactId>bom</artifactId>
                <version>2.16.40</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.reactivestreams</groupId>
                <artifactId>reactive-streams</artifactId>
                <version>1.0.3</version>
            </dependency>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-codec-http</artifactId>
                <version>4.1.61.Final</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/io.netty/netty-handler -->
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-handler</artifactId>
                <version>4.1.61.Final</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/io.netty/netty-codec-http -->
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-codec-http</artifactId>
                <version>4.1.61.Final</version>
            </dependency>
  • JDK version used: openjdk version “1.8.0_41”
  • Operating System and version: Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GingerMooncommented, Apr 19, 2021

@debora-ito Thanks for the reply. I did do the same as you mentioned but still had the error. Our company’s policy (maven enforce) requires that all projects must depend on netty-all.jar, which has conflicts with aws-sdk-java-v2. Some of the maven errors are bleow:

  Found in:
    io.netty:netty-handler:jar:4.1.43.Final:runtime
    io.netty:netty-all:jar:4.0.36.Final:compile
  Duplicate classes:
    io/netty/handler/timeout/IdleStateHandler.class
0reactions
snehal-koltecommented, Nov 15, 2021

@GingerMoon I am facing the same issue. As shown in the above screenshot, Would you please share how i can verify conflict dependencies? I am using intellij idk.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug dependency conflicts in Maven and Gradle
It seems to be weird: library browserup-proxy-core uses netty-codec (and excludes netty-all , by the way). But its dependency littleproxy does ...
Read more >
Detecting dependency conflicts with Maven - Stack Overflow
To detect all the transitive dependencies you can use the maven-dependency-plugin : mvn dependency:tree -Dverbose.
Read more >
Solving Dependency Conflicts in Maven - DZone
Maven dependency conflicts can be really hard to solve. The purpose of this post is for readers to better understand what a version...
Read more >
io.netty » netty-all - Maven Repository
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients.
Read more >
Project Dependencies - Logstash/Gelf Loggers
GroupId ArtifactId Version Type com.fasterxml.jackson.core jackson‑annotations 2.13.1 jar com.fasterxml.jackson.core jackson‑core 2.13.1 jar com.fasterxml.jackson.dataformat jackson‑dataformat‑csv 2.10.5 jar
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found