Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.4.2 - Redisson Client - DNS Resolution Problem at start

I'm upgrading my Spring Boot version from 2.1.x to 2.4.2. When I compiled and run the code, I got the following warning:

Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider,fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
java.lang.ClassNotFoundException: io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider

When I deploy the project to DEV environment which is in AWS and CentOS machine, there is no such warning message in the logs.

Thanks,

like image 471
Baris Ucakturk Avatar asked Jan 29 '21 12:01

Baris Ucakturk


5 Answers

I needed a version in addition to classifier:

    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-resolver-dns-native-macos</artifactId>
        <scope>runtime</scope>
        <classifier>osx-x86_64</classifier>
        <version>4.1.59.Final</version>
    </dependency>

scope is optional but classifier is required.

For the latest version, see: https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos

Example: Latest version for M1 macs (aarch_64), as of 2022-01:

<classifier>osx-aarch_64</classifier>
<version>4.1.72.Final</version>
like image 131
Curtis Yallop Avatar answered Oct 16 '22 12:10

Curtis Yallop


For this pull request https://github.com/netty/netty/pull/10848, the log level changes from "debug" to "warn."

To solve this problem, you can add this dependency:

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>
like image 29
cavelling Avatar answered Oct 16 '22 12:10

cavelling


Gradle syntax if you prefer:

compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-x86_64"

and for ARM-based macbook:

compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-aarch_64"
like image 40
Peter Cui Avatar answered Oct 16 '22 10:10

Peter Cui


As suggested here, add the following dependency in your module.

<properties>
  <version.netty>4.1.59.Final</version.netty>
</properties>

<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-resolver-dns-native-macos</artifactId>
  <version>${version.netty}</version>
  <scope>runtime</scope>
  <classifier>osx-x86_64</classifier>
</dependency>

If you face this issue only while running your app locally on macOS, you may add the dependency for a specific maven profile, e.g. "local".

<profiles>
  <profile>
    <id>local</id>
    <dependencies>
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-resolver-dns-native-macos</artifactId>
        <version>${version.netty}</version>
        <scope>runtime</scope>
        <classifier>osx-x86_64</classifier>
      </dependency>
    </dependencies>
  </profile>
</profiles>

You can avoid specifying version if you import netty-bom in dependencyManagement.

like image 3
Somu Avatar answered Oct 16 '22 12:10

Somu


If you have Gradle and want to include netty only locally you can make use of https://github.com/google/osdetector-gradle-plugin

plugins {
    id("com.google.osdetector") version "1.7.0"
}

dependencies {
    if (osdetector.arch.equals("aarch_64")) {
        implementation("io.netty:netty-all")
    }
}
like image 3
pixel Avatar answered Oct 16 '22 11:10

pixel