Skip to content
Advertisement

Spring Api-Gateway: (M1) java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos_aarch_64

Just to clearify this only occurs on M1 Mac, the intel version doesn’t seem to have this problem.

JDK 17

openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Homebrew (build 17.0.1+1)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.1+1, mixed mode, sharing)

# List of all JDK
Matching Java Virtual Machines (2):
    17.0.1 (arm64) "Homebrew" - "OpenJDK 17.0.1" /opt/homebrew/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home
    16.0.2 (arm64) "Azul Systems, Inc." - "Zulu 16.32.15" /Users/xxxxxx/Library/Java/JavaVirtualMachines/azul-16.0.2/Contents/Home
/opt/homebrew/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home

Project Diagram

enter image description here

Problem:

java.lang.UnsatisfiedLinkError exception is thrown when trying to access one of the microservice through API-Gateway. For example, http://localhost:8082/API-USER/users/status/ok will throw this exception.

The return value is correct, API-Gateway continuse to run dispite the annoying exception.

Caused by: java.lang.UnsatisfiedLinkError: failed to load the required native library
    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.ensureAvailability(MacOSDnsServerAddressStreamProvider.java:110) ~[netty-resolver-dns-classes-macos-4.1.75.Final.jar:4.1.75.Final]
Caused by: java.lang.UnsatisfiedLinkError: failed to load the required native library

    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.<init>(MacOSDnsServerAddressStreamProvider.java:120) ~[netty-resolver-dns-classes-macos-4.1.75.Final.jar:4.1.75.Final]
    ... 202 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: could not load a native library: netty_resolver_dns_native_macos_aarch_64
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:224) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.loadNativeLibrary(MacOSDnsServerAddressStreamProvider.java:92) ~[netty-resolver-dns-classes-macos-4.1.75.Final.jar:4.1.75.Final]
    at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.<clinit>(MacOSDnsServerAddressStreamProvider.java:77) ~[netty-resolver-dns-classes-macos-4.1.75.Final.jar:4.1.75.Final]
    at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
Caused by: java.lang.UnsatisfiedLinkError: could not load a native library: netty_resolver_dns_native_macos_aarch_64

    at java.base/java.lang.Class.forName(Class.java:467) ~[na:na]
    at io.netty.resolver.dns.DnsServerAddressStreamProviders$1.run(DnsServerAddressStreamProviders.java:50) ~[netty-resolver-dns-4.1.75.Final.jar:4.1.75.Final]
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
    at io.netty.resolver.dns.DnsServerAddressStreamProviders.<clinit>(DnsServerAddressStreamProviders.java:46) ~[netty-resolver-dns-4.1.75.Final.jar:4.1.75.Final]
    ... 196 common frames omitted
    Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_resolver_dns_native_macos
        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:224) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
        at io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.loadNativeLibrary(MacOSDnsServerAddressStreamProvider.java:95) ~[netty-resolver-dns-classes-macos-4.1.75.Final.jar:4.1.75.Final]
        ... 202 common frames omitted
    Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_resolver_dns_native_macos.jnilib
        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:166)
    Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_resolver_dns_native_macos.jnilib

        ... 203 common frames omitted
        Suppressed: java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos in java.library.path: /Users/erichuang/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
            at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
            at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
            at java.base/java.lang.System.loadLibrary(System.java:1989)
            at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
            at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:376)
            at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:146)
            ... 203 common frames omitted
            Suppressed: java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos in java.library.path: /Users/erichuang/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
                at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
                at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
                at java.base/java.lang.System.loadLibrary(System.java:1989)
                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
                at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.base/java.lang.reflect.Method.invoke(Method.java:568)
                at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:410)
                at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:402)
                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:368)
                ... 204 common frames omitted
Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_resolver_dns_native_macos_aarch_64.jnilib
    at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:166) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
    ... 203 common frames omitted
    Suppressed: java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos_aarch_64 in java.library.path: /Users/erichuang/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429) ~[na:na]
Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_resolver_dns_native_macos_aarch_64.jnilib

        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818) ~[na:na]
        at java.base/java.lang.System.loadLibrary(System.java:1989) ~[na:na]
        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:376) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:146) ~[netty-common-4.1.75.Final.jar:4.1.75.Final]
        ... 203 common frames omitted
        Suppressed: java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos_aarch_64 in java.library.path: /Users/erichuang/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
            at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
            at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
            at java.base/java.lang.System.loadLibrary(System.java:1989)
            at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:568)
            at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:410)
            at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
            at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:402)
            at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:368)
            ... 204 common frames omitted

Question

Does any one know how to mitigate this error?

I tired…

Both of these links suggested to add netty-tcnative-boringssl-static dependency but that didn’t work as well….

API-Gateway : build.gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    // https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static
    implementation group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: '2.0.51.Final'


}

Thanks for helping

Advertisement

Answer

Found an issue on GitHub: https://github.com/netty/netty/issues/11020

Get the newest version: https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos

Still doesn’t explain why this problem occurs, but here it is that fixed the issue for me:

Maven

        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-resolver-dns-native-macos</artifactId>
          <version>XXX</version>
          <classifier>osx-aarch_64</classifier>
        </dependency>

Gradle

implementation group: 'io.netty', name: 'netty-resolver-dns-native-macos', version: 'xxx', classifier: 'osx-aarch_64'
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement