Spring Boot Version 3.0.0, GraalVM 22.3.0。

I use GraalVM and Native Image to build a binary execution file.

The http interface annotation @HttpExchange is used in the project.

Reports this error at the start of the project.

2022-12-14T17:28:03.425+08:00  WARN 8900 --- [           main] reactor.core.Exceptions                  : throwIfFatal detected a jvm fatal exception, which is thrown and logged below:

java.lang.ExceptionInInitializerError: null
        at io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder$1.provider(DnsServerAddressStreamProviders.java:150) ~[na:na]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder$1.<init>(DnsServerAddressStreamProviders.java:130) ~[na:na]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders$DefaultProviderHolder.<clinit>(DnsServerAddressStreamProviders.java:128) ~[na:na]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders.unixDefault(DnsServerAddressStreamProviders.java:117) ~[na:na]
        at io.netty.resolver.dns.DnsServerAddressStreamProviders.platformDefault(DnsServerAddressStreamProviders.java:113) ~[na:na]
        at io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:60) ~[na:na]
        at reactor.netty.transport.NameResolverProvider.newNameResolverGroup(NameResolverProvider.java:479) ~[na:na]
        at reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver(TcpResources.java:315) ~[spring-boot3.x-demo.exe:1.1.0]
        at reactor.netty.http.HttpResources.getOrCreateDefaultResolver(HttpResources.java:162) ~[spring-boot3.x-demo.exe:1.1.0]
        at reactor.netty.http.client.HttpClientConfig.defaultAddressResolverGroup(HttpClientConfig.java:395) ~[spring-boot3.x-demo.exe:1.1.0]
        at reactor.netty.transport.ClientTransportConfig.resolverInternal(ClientTransportConfig.java:225) ~[spring-boot3.x-demo.exe:1.1.0]
        at reactor.netty.http.client.HttpClientConfig.resolverInternal(HttpClientConfig.java:449) ~[spring-boot3.x-demo.exe:1.1.0]
        at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:265) ~[na:na]
        at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58) ~[na:na]
        at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77) ~[na:na]
        at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) ~[na:na]
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[spring-boot3.x-demo.exe:3.5.0]
        at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:272) ~[na:na]
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[spring-boot3.x-demo.exe:3.5.0]
        at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55) ~[na:na]
        at reactor.core.publisher.Mono.subscribe(Mono.java:4444) ~[spring-boot3.x-demo.exe:3.5.0]
        at reactor.core.publisher.Mono.block(Mono.java:1733) ~[spring-boot3.x-demo.exe:3.5.0]
        at org.springframework.web.service.invoker.HttpServiceMethod$ResponseFunction.execute(HttpServiceMethod.java:296) ~[na:na]
        at org.springframework.web.service.invoker.HttpServiceMethod.invoke(HttpServiceMethod.java:105) ~[na:na]
        at org.springframework.web.service.invoker.HttpServiceProxyFactory$HttpServiceMethodInterceptor.invoke(HttpServiceProxyFactory.java:271) ~[na:na]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-boot3.x-demo.exe:6.0.2]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:218) ~[na:na]
        at jdk.proxy4/jdk.proxy4.$Proxy44.getTodo(Unknown Source) ~[na:na]
        at com.tqz.spring.boot3.x.demo.config.HttpInterfaceConfig.lambda$clr$0(HttpInterfaceConfig.java:43) ~[spring-boot3.x-demo.exe:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:767) ~[spring-boot3.x-demo.exe:3.0.0]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:751) ~[spring-boot3.x-demo.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot3.x-demo.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot3.x-demo.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot3.x-demo.exe:3.0.0]
        at com.tqz.spring.boot3.x.demo.Application.main(Application.java:52) ~[spring-boot3.x-demo.exe:na]
Caused by: java.lang.NullPointerException: null
        at java.base@17.0.5/sun.net.dns.ResolverConfigurationImpl.stringToList(ResolverConfigurationImpl.java:69) ~[na:na]
        at java.base@17.0.5/sun.net.dns.ResolverConfigurationImpl.loadConfig(ResolverConfigurationImpl.java:136) ~[na:na]
        at java.base@17.0.5/sun.net.dns.ResolverConfigurationImpl.nameservers(ResolverConfigurationImpl.java:159) ~[na:na]
        at jdk.naming.dns@17.0.5/com.sun.jndi.dns.DnsContextFactory.serversForUrls(DnsContextFactory.java:149) ~[spring-boot3.x-demo.exe:na]
        at jdk.naming.dns@17.0.5/com.sun.jndi.dns.DnsContextFactory.getContext(DnsContextFactory.java:81) ~[spring-boot3.x-demo.exe:na]
        at jdk.naming.dns@17.0.5/com.sun.jndi.dns.DnsContextFactory.urlToContext(DnsContextFactory.java:120) ~[spring-boot3.x-demo.exe:na]
        at jdk.naming.dns@17.0.5/com.sun.jndi.dns.DnsContextFactory.getInitialContext(DnsContextFactory.java:64) ~[spring-boot3.x-demo.exe:na]
        at java.naming@17.0.5/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:732) ~[spring-boot3.x-demo.exe:na]
        at java.naming@17.0.5/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305) ~[spring-boot3.x-demo.exe:na]
        at java.naming@17.0.5/javax.naming.InitialContext.init(InitialContext.java:236) ~[spring-boot3.x-demo.exe:na]
        at java.naming@17.0.5/javax.naming.InitialContext.<init>(InitialContext.java:208) ~[spring-boot3.x-demo.exe:na]
        at java.naming@17.0.5/javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:130) ~[spring-boot3.x-demo.exe:na]
        at io.netty.resolver.dns.DirContextUtils.addNameServers(DirContextUtils.java:49) ~[na:na]
        at io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider.<clinit>(DefaultDnsServerAddressStreamProvider.java:53) ~[na:na]
        ... 35 common frames omitted

Comment From: sbrannen

If you're experiencing this on mac OS, the following might help.

https://stackoverflow.com/questions/65954571/spring-boot-2-4-2-dns-resolution-problem-at-start-on-apple-m1/67769368#67769368

Please let us know if that resolves the issue for you.

Comment From: tian-qingzhao

I'm very sorry, my operating system is window10, I think the link you sent can not solve my problem.

Comment From: sbrannen

@violetagg, have you encountered this before on Windows?

Comment From: violetagg

May be this issue https://github.com/oracle/graal/issues/4304 ?

Comment From: tian-qingzhao

I did that, and I still have that problem. But it seems my problems are the same as theirs.

Spring Native Image reports ExceptionInInitializerError: null for Netty DnsServerAddressStreamProviders

Comment From: violetagg

@tian-qingzhao Did you add also --initialize-at-run-time=sun.net.dns.ResolverConfigurationImpl as they described?

Comment From: tian-qingzhao

Sorry, I didn't add that parameter just now. Now the problem has been solved. Thank you very much for your help!

Comment From: sbrannen

Thanks, @violetagg, for helping sort this out! 👍