当前位置: 首页 > 知识库问答 >
问题:

GraalVM本机映像的运行时错误DnsServerAddressStreamProviders$DefaultProviderHolder

李胡媚
2023-03-14

我正在尝试使用GraalVM为spring cloud gateway构建本机映像。我已经成功构建了一个可以启动的本机映像,但在第一个http请求时,我出现了以下错误:

java.lang.NoClassDefFoundError: Could not initialize class io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:239) ~[na:na]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders.unixDefault(DnsServerAddressStreamProviders.java:107) ~[gatewayapplication.exe:4.1.60.Final]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders.platformDefault(DnsServerAddressStreamProviders.java:103) ~[gatewayapplication.exe:4.1.60.Final]
        at io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:60) ~[na:na]
        at reactor.netty.transport.NameResolverProvider.newNameResolverGroup(NameResolverProvider.java:405) ~[na:na]
        at reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver(TcpResources.java:306) ~[na:na]
        at reactor.netty.http.HttpResources.getOrCreateDefaultResolver(HttpResources.java:140) ~[na:na]
        at reactor.netty.http.client.HttpClientConfig.defaultAddressResolverGroup(HttpClientConfig.java:380) ~[na:na]
        at reactor.netty.transport.ClientTransportConfig.resolverInternal(ClientTransportConfig.java:219) ~[na:na]
        at reactor.netty.http.client.HttpClientConfig.resolverInternal(HttpClientConfig.java:434) ~[na:na]
        at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:264) ~[na:na]
        at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57) ~[na:na]
        at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:76) ~[na:na]
        at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) ~[na:na]
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[na:na]
        at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:271) ~[na:na]

添加此标志没有帮助

--initialize-at-run-time=io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder

并在反射配置中添加一个条目,不是吗

{
  "name":"io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder"
}

该项目可以在这里找到:https://github.com/hanouard/demo-native-gateway

你知道是什么导致了这个错误吗?

共有2个答案

景哲
2023-03-14

实际上,Spring Native还不支持我想要实现的目标:https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#support-spring-cloud

我想他们更新了文档,因为我在0.9.1版本中看到了对spring cloud gateway的支持。

汲睿
2023-03-14

在将Spring Boot从2.4.3升级到2.4.4后,我遇到了相同的问题,我的错误如下:

java.lang.AbstractMethodError: Receiver class reactor.netty.http.client.HttpClientConfig does not define or inherit an implementation of the resolved method 'abstract io.netty.resolver.AddressResolverGroup defaultAddressResolverGroup()' of abstract class reactor.netty.transport.ClientTransportConfig.
    at reactor.netty.transport.ClientTransportConfig.resolverInternal(ClientTransportConfig.java:219)
    at reactor.netty.http.client.HttpClientConfig.resolverInternal(HttpClientConfig.java:420)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:262)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:76)
    at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:269)
    at reactor.core.publisher.Flux.subscribe(Flux.java:8227)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73)
    at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281)
    at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860)
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
    at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281)
    at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860)
    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
    at reactor.core.publisher.MonoFilterWhen$MonoFilterWhenMain.onNext(MonoFilterWhen.java:149)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397)
    at reactor.core.publisher.MonoFilterWhen$MonoFilterWhenMain.onSubscribe(MonoFilterWhen.java:112)
    at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onNext(FluxConcatMap.java:250)
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:98)
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onNext(FluxDematerialize.java:44)
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270)
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228)
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.request(FluxDematerialize.java:127)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:235)
    at reactor.core.publisher.FluxDematerialize$DematerializeSubscriber.onSubscribe(FluxDematerialize.java:77)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
    at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62)
    at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:448)
    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:218)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164)
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:255)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.Mono.subscribeWith(Mono.java:4265)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4121)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4057)
    at org.springframework.test.web.reactive.server.HttpHandlerConnector.lambda$doConnect$2(HttpHandlerConnector.java:98)
    at org.springframework.mock.http.client.reactive.MockClientHttpRequest.lambda$null$2(MockClientHttpRequest.java:125)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.FluxConcatIterable$ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:147)
    at reactor.core.publisher.FluxConcatIterable.subscribe(FluxConcatIterable.java:60)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.Mono.subscribeWith(Mono.java:4265)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4121)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4057)
    at org.springframework.test.web.reactive.server.HttpHandlerConnector.doConnect(HttpHandlerConnector.java:112)
    at org.springframework.test.web.reactive.server.HttpHandlerConnector.lambda$connect$0(HttpHandlerConnector.java:79)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
    at reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber.run(MonoSubscribeOn.java:126)
    at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
    at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

我可以通过添加以下bean来修复它:

import org.springframework.cloud.gateway.config.HttpClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.netty.resolver.DefaultAddressResolverGroup;
import reactor.netty.http.client.HttpClient;

@Configuration
public class HttpClientResolverFixConfig {

    @Bean
    public HttpClientCustomizer httpClientResolverCustomizer() {
        return new HttpClientCustomizer() {

            @Override
            public HttpClient customize(HttpClient httpClient) {
                return httpClient.resolver(DefaultAddressResolverGroup.INSTANCE);
            }
        };
    }

}

请查看此处以了解更多详细信息:https://github.com/reactor/reactor-netty/issues/1431

 类似资料:
  • 我正在尝试使用graalVM v20.0.0CE创建一个简单的hello world本地映像。 最初,我收到了一个“本机工具链”错误,但从“x86 Native Tools Command Prompt for VS2017”启动了一个命令行,我就克服了这个障碍。 现在的问题是一串链接器错误: java.lib(jni_util.obj):错误LNK2019:函数jni _打印字符串中引用了未解析

  • 我设法为springboot fat jar构建了本机映像,但当我运行它时,它抛出了异常:“”。我尝试添加一个默认构造和一个空的init()方法,但都失败了。如何克服此异常并使本机映像运行? 以下是完整日志:

  • 亲爱的,我下面的原生图像构建教程由Quarkus创建原生graalvm,但我得到了下面的错误: 我的环境:OS:CentOS 7 Quarkus:0.11.0 Java:Open JDK 1.8.0_181 GraalVM:1.0.0-rc13 使用quarkus在你的应用程序中没有主要方法,但如何使用graal原生图像使其工作?

  • 我正在试验在GraalVM本机映像中从Java代码运行JS脚本。 Java代码如下所示: JS代码只是通过调用对象上的一个方法来尝试使用它,例如: 当在GraalVM中运行时,这项功能有效,但当创建本机映像时,它会失败,并出现以下错误: 如果我只是像在

  • 在哪里可以找到使用 -H:配置文件目录设置的 GraalVM 配置文件的文档/模式

  • 我正在尝试用Dockers创建一个GraalVM本地映像。我已经创建了一个Micronaut项目,并成功创建了jar应用程序,并在docker中运行;此外,我已经用这个jar文件创建了一个GraalVM本机映像,现在可以运行这个应用程序,但我需要在docker中运行一个GraalVM本机映像,在论坛中寻找答案。我发现有必要在docker中构建本机映像。因此我尝试了这个docker文件: 它不会抛出