spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 356 forks source link

session-redis-webflux fails with GraalVM 22.1 #1554

Closed mhalbritter closed 2 years ago

mhalbritter commented 2 years ago
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment GraalVM CE 22.1.0-dev (build 17.0.3+4-jvmci-22.1-b03)
OpenJDK 64-Bit Server VM GraalVM CE 22.1.0-dev (build 17.0.3+4-jvmci-22.1-b03, mixed mode, sharing)

run fails with

2022-03-29 09:10:33.384  INFO 153907 --- [           main] o.s.nativex.NativeListener               : AOT mode enabled

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.4)

2022-03-29 09:10:33.394  INFO 153907 --- [           main] c.e.s.SessionRedisWebfluxApplication     : Starting SessionRedisWebfluxApplication v0.0.1-SNAPSHOT using Java 17.0.3 on fedora with PID 153907 (/home/moe/Projects/spring-native/samples/session-redis-webflux/target/session-redis-webflux started by moe in /home/moe/Projects/spring-native/samples/session-redis-webflux)
2022-03-29 09:10:33.394  INFO 153907 --- [           main] c.e.s.SessionRedisWebfluxApplication     : No active profile set, falling back to 1 default profile: "default"
2022-03-29 09:10:33.413  WARN 153907 --- [           main] o.s.security.core.userdetails.User       : User.withDefaultPasswordEncoder() is considered unsafe for production and is only intended for sample applications.
2022-03-29 09:10:33.516  WARN 153907 --- [           main] .r.c.ReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lettuceClientResources': Unexpected exception during bean creation; nested exception is java.lang.ExceptionInInitializerError
2022-03-29 09:10:33.517 ERROR 153907 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Native reflection configuration for io.netty.channel.socket.nio.NioDatagramChannel.<init>() is missing.
mhalbritter commented 2 years ago

This looks like something is missing in reflection-config, but I just double-checked that it works with Graal 22.0.

mhalbritter commented 2 years ago

Here's the full exception:

java.lang.NoSuchMethodException: io.netty.channel.socket.nio.NioDatagramChannel.<init>()
    at java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[session-redis-webflux:na]
    at java.lang.Class.getConstructor(DynamicHub.java:2271) ~[session-redis-webflux:na]
    at io.netty.channel.ReflectiveChannelFactory.<init>(ReflectiveChannelFactory.java:34) ~[na:na]
    at io.netty.resolver.dns.DnsNameResolverBuilder.channelType(DnsNameResolverBuilder.java:117) ~[na:na]
    at io.lettuce.core.resource.AddressResolverGroupProvider$DefaultDnsAddressResolverGroupWrapper.<clinit>(AddressResolverGroupProvider.java:57) ~[na:na]
    at io.lettuce.core.resource.AddressResolverGroupProvider.<clinit>(AddressResolverGroupProvider.java:35) ~[na:na]
    at io.lettuce.core.resource.DefaultClientResources.<clinit>(DefaultClientResources.java:112) ~[session-redis-webflux:6.1.6.RELEASE]
    at org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration.lettuceClientResources(LettuceConnectionConfiguration.java:71) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.autoconfigure.data.redis.ContextBootstrapInitializer.lambda$registerLettuceConnectionConfiguration_lettuceClientResources$2(ContextBootstrapInitializer.java:20) ~[na:na]
    at org.springframework.boot.autoconfigure.data.redis.ContextBootstrapInitializer$$Lambda$52cce717ea90eda19c73e2f7c79eeab475efe3a6.applyWithException(Unknown Source) ~[na:na]
    at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$ThrowableFunction.apply(BeanDefinitionRegistrar.java:294) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.aot.beans.factory.InjectedElementResolver.create(InjectedElementResolver.java:67) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$BeanInstanceContext.create(BeanDefinitionRegistrar.java:211) ~[na:na]
    at org.springframework.boot.autoconfigure.data.redis.ContextBootstrapInitializer.lambda$registerLettuceConnectionConfiguration_lettuceClientResources$3(ContextBootstrapInitializer.java:20) ~[na:na]
    at org.springframework.boot.autoconfigure.data.redis.ContextBootstrapInitializer$$Lambda$c46bd4ee696b854ac17d02c1e776fc395d0491b9.applyWithException(Unknown Source) ~[na:na]
    at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$ThrowableFunction.apply(BeanDefinitionRegistrar.java:294) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.aot.beans.factory.BeanDefinitionRegistrar.lambda$instanceSupplier$0(BeanDefinitionRegistrar.java:115) ~[na:na]
    at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$$Lambda$a3df89430a3ba7d397d0053371a7f0bbfc99ecb2.get(Unknown Source) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$2c40051508af481f3e2b011afbd5800cdeae9fd3.getObject(Unknown Source) ~[na:na]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[session-redis-webflux:0.11.4-SNAPSHOT]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[session-redis-webflux:5.3.16]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[session-redis-webflux:5.3.16]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[session-redis-webflux:2.6.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[session-redis-webflux:2.6.4]
    at com.example.sessionrediswebflux.SessionRedisWebfluxApplication.main(SessionRedisWebfluxApplication.java:10) ~[session-redis-webflux:0.0.1-SNAPSHOT]
mhalbritter commented 2 years ago

Works now, using Graal 22.1 built from this commit https://github.com/oracle/graal/commit/3eb1d111ab25565acbbc015128a2c787656e2675