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

RabbitMQ Regression with GraalVM 22.1 #1643

Closed goafabric closed 2 years ago

goafabric commented 2 years ago

While the implicit upgrade of paketo to GraalVM 22.1 fixed things for JPA. It on the other hand broke RabbitMQ Hints

While this branch worked flawlessly 2 months ago (it bootstraps the application during build to verify that application start works) https://github.com/goafabric/event-dispatcher-service/actions/runs/2225017519

A direct copy now breaks: https://github.com/goafabric/event-dispatcher-service/actions/runs/2507912855

See error below -- the @Queuebinding inside LoggerAdapter brakes. Upgrading or downgrading spring (native) wont change anything The only difference i can spot is graalvm 22.0.1 vs 22.1

I guess the Class LoggerAdapter alone should be enough to cause the behaviour

-- cut --- com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.amqp.rabbit.annotation.QueueBinding, interface org.springframework.core.annotation.SynthesizedAnnotation] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. 1187 2022-06-16 09:09:19.706 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed 1188 1189 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loggerAdapter': Initialization of bean failed; nested exception is com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.springframework.amqp.rabbit.annotation.QueueBinding, interface org.springframework.core.annotation.SynthesizedAnnotation] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options.

goafabric commented 2 years ago

Honestly .. I would also expect that the graalvm version / paketo build is tied to the spring-native version. I know that this can be configured manually .. but neither was i able to understand the versioning scheme.

And I think this should be the default behaviour .. otherwise builds are never repeatable .. and thats a huge bummer.

The next Milestone also has a already fixed issue due to GraalVM behaviour change: https://github.com/spring-projects-experimental/spring-native/issues/1584

sdeleuze commented 2 years ago

I understand the pain of non repeatable builds with Buildpacks and the fact that the versioning scheme is not easy to understand. I will raise that point to Spring Boot team for Spring Boot 3.

goafabric commented 2 years ago

@sdeleuze thank you

goafabric commented 2 years ago

just to add .. its actually the same graalvm 22.1 version here .. just the build packs internal version differ 5.2.1 vs 5.2.3 however i was not able to figure out which parameter that will be .. very confusing configured to the latest one documented here https://paketo.io//docs/howto/java/#configure-the-graalvm-version => gcr.io/paketo-buildpacks/java-native-image:5.12.0 => this falls back to graalvm 21.3 and than works

goafabric commented 2 years ago

With Spring Boot 3.0 M5 it works nearly out of the Box. Just a hint for RabbitHealthIndicator is missing

`static class ApplicationRuntimeHints implements RuntimeHintsRegistrar {

    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
        registerReflection(RabbitHealthIndicator.class, hints);
    }

    private void registerReflection(Class clazz, RuntimeHints hints) {
        Arrays.stream(clazz.getDeclaredConstructors()).forEach(
                r -> hints.reflection().registerConstructor(r, ExecutableMode.INVOKE));
        Arrays.stream(clazz.getDeclaredMethods()).forEach(
                r -> hints.reflection().registerMethod(r, ExecutableMode.INVOKE));
    }

}`
wilkinsona commented 2 years ago

Thanks, @goafabric. I think we've fixed that for RC1: https://github.com/spring-projects/spring-boot/issues/32541.

goafabric commented 2 years ago

@wilkinsona cool thank you