AxonFramework / extension-spring-aot

Axon Framework extension for Spring Ahead of Time compilation support.
Apache License 2.0
4 stars 0 forks source link

Command handler interceptor causes errors in running Spring Boot AOT application #192

Open xvotro02 opened 2 weeks ago

xvotro02 commented 2 weeks ago

Basic information

Steps to reproduce

Define a command handler interceptor on aggregate. Run Spring Boot application in native mode: a. mvn spring-boot:process-aot +java -DspringAot=true -jar your-application.jar b. org.graalvm.buildtools:native-maven-plugin + mvn spring-boot:build-image with maven native profile + run image

Expected behaviour

Command handler interceptor works as in normal mode (without AOT and native image).

Actual behaviour

Error appears in running application when the interceptor should be executed:

The program tried to reflectively invoke method public void {aggregateClass}.intercept({command}) without it being registered for runtime reflection. Add public void {aggregateClass}.intercept({command}) to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
2024-09-30 13:29:33     at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:72)
2024-09-30 13:29:33     at java.base@21.0.4/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77)
2024-09-30 13:29:33     at java.base@21.0.4/java.lang.reflect.Method.invoke(Method.java:577)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(AnnotatedMessageHandlingMember.java:153)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.MessageHandlerInterceptorDefinition$InterceptedMessageHandlingMember.handle(MessageHandlerInterceptorDefinition.java:123)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64)
2024-09-30 13:29:33     at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.lambda$handle$1(TracingHandlerEnhancerDefinition.java:84)
2024-09-30 13:29:33     at org.axonframework.tracing.Span.runCallable(Span.java:132)
2024-09-30 13:29:33     at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.handle(TracingHandlerEnhancerDefinition.java:84)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.lambda$handle$0(AnnotatedCommandHandlerInterceptor.java:59)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory.callWithInterceptorChain(InterceptorChainParameterResolverFactory.java:75)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.handle(AnnotatedCommandHandlerInterceptor.java:56)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.lambda$handle$0(AnnotatedCommandHandlerInterceptor.java:60)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory.callWithInterceptorChain(InterceptorChainParameterResolverFactory.java:75)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.handle(AnnotatedCommandHandlerInterceptor.java:56)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.lambda$handle$0(AnnotatedCommandHandlerInterceptor.java:60)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory.callWithInterceptorChain(InterceptorChainParameterResolverFactory.java:75)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.handle(AnnotatedCommandHandlerInterceptor.java:56)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.lambda$handle$0(AnnotatedCommandHandlerInterceptor.java:60)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory.callWithInterceptorChain(InterceptorChainParameterResolverFactory.java:75)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.handle(AnnotatedCommandHandlerInterceptor.java:56)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.lambda$handle$0(AnnotatedCommandHandlerInterceptor.java:60)
2024-09-30 13:29:33     at org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory.callWithInterceptorChain(InterceptorChainParameterResolverFactory.java:75)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedCommandHandlerInterceptor.handle(AnnotatedCommandHandlerInterceptor.java:56)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedAggregate.handle(AnnotatedAggregate.java:433)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedAggregate.lambda$handle$3(AnnotatedAggregate.java:398)
2024-09-30 13:29:33     at org.axonframework.messaging.Scope.executeWithResult(Scope.java:111)
2024-09-30 13:29:33     at org.axonframework.modelling.command.inspection.AnnotatedAggregate.handle(AnnotatedAggregate.java:405)
2024-09-30 13:29:33     at org.axonframework.modelling.command.LockAwareAggregate.handle(LockAwareAggregate.java:97)
2024-09-30 13:29:33     at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:568)
2024-09-30 13:29:33     at org.axonframework.modelling.command.AggregateAnnotationCommandHandler$AggregateCommandHandler.handle(AggregateAnnotationCommandHandler.java:557)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:57)
2024-09-30 13:29:33     at cz.aura.lis.axon.logging.MdcInterceptor.handle(MdcInterceptor.java:29)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.messaging.interceptors.CorrelationDataInterceptor.handle(CorrelationDataInterceptor.java:67)
2024-09-30 13:29:33     at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55)
2024-09-30 13:29:33     at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:77)
2024-09-30 13:29:33     at org.axonframework.commandhandling.SimpleCommandBus.lambda$handle$2(SimpleCommandBus.java:200)
2024-09-30 13:29:33     at org.axonframework.tracing.Span.runSupplier(Span.java:163)
2024-09-30 13:29:33     at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:191)
2024-09-30 13:29:33     at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:165)
2024-09-30 13:29:33     at org.axonframework.commandhandling.SimpleCommandBus.lambda$dispatch$1(SimpleCommandBus.java:131)
2024-09-30 13:29:33     at org.axonframework.tracing.Span.run(Span.java:101)
2024-09-30 13:29:33     at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:125)
2024-09-30 13:29:33     at org.axonframework.axonserver.connector.command.AxonServerCommandBus$CommandProcessingTask.lambda$run$1(AxonServerCommandBus.java:310)
2024-09-30 13:29:33     at org.axonframework.tracing.Span.run(Span.java:101)
2024-09-30 13:29:33     at org.axonframework.axonserver.connector.command.AxonServerCommandBus$CommandProcessingTask.run(AxonServerCommandBus.java:308)
2024-09-30 13:29:33     at org.axonframework.axonserver.connector.PriorityRunnable.run(PriorityRunnable.java:58)
2024-09-30 13:29:33     at java.base@21.0.4/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
2024-09-30 13:29:33     at java.base@21.0.4/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
2024-09-30 13:29:33     at java.base@21.0.4/java.lang.Thread.runWith(Thread.java:1596)
2024-09-30 13:29:33     at java.base@21.0.4/java.lang.Thread.run(Thread.java:1583)
2024-09-30 13:29:33     at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:902)
2024-09-30 13:29:33     at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:878)
smcvb commented 1 week ago

Thanks for filing this issue with us, @xvotro02! If you could have a sample application showing the behavior consistently, that would greatly help us resolve this issue soon. If not, it will take some time for us to set that up. This is doable, but it would thus take longer to get to a resolution, which I want you to be aware of.

Any progress on the issue will be shared here for your convenience.

smcvb commented 1 week ago

I wanted to inform you that we're looking into this, @xvotro02. As stated earlier, as soon as we have a solution, we'll update this issue accordingly.