Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring AOT doesn't work when using custom or spring beans as parameters in handler methods #183

Closed
abuijze opened this issue Sep 18, 2024 · 1 comment

Comments

@abuijze
Copy link
Member

abuijze commented Sep 18, 2024

Basic information

  • Axon Framework version: 4.10.0
  • JDK version: Unrelated
  • Spring (Boot) version: 3.3.0
  • Spring Ahead of Time Extension version: 4.10.0

Steps to reproduce

Define a handler that defines a Spring bean as parameter.
Run mvn spring-boot:process-aot

Expected behaviour

The build passes and creates the Application Context definitions and reflection declarations for the handler methods

Actual behaviour

The build fails with:

Exception in thread "main" org.axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolve parameter 1 (CommandGateway) in handler public void io.axoniq.demo.bikerental.rental.command.Bike.handle(io.axoniq.demo.bikerental.coreapi.rental.RegisterBikeCommand,org.axonframework.commandhandling.gateway.CommandGateway).
        at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.<init>(AnnotatedMessageHandlingMember.java:82)
        at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMemberDefinition.lambda$createHandler$0(AnnotatedMessageHandlingMemberDefinition.java:54)
        at java.base/java.util.Optional.map(Optional.java:260)
        at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMemberDefinition.createHandler(AnnotatedMessageHandlingMemberDefinition.java:51)
        at org.axonframework.messaging.annotation.MultiHandlerDefinition.createHandler(MultiHandlerDefinition.java:183)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.initializeMessageHandlers(AnnotatedHandlerInspector.java:206)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.initialize(AnnotatedHandlerInspector.java:197)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.createInspector(AnnotatedHandlerInspector.java:153)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.inspectType(AnnotatedHandlerInspector.java:138)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.inspectType(AnnotatedHandlerInspector.java:120)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.inspectType(AnnotatedHandlerInspector.java:102)
        at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.inspectType(AnnotatedHandlerInspector.java:88)
        at org.axonframework.springboot.aot.MessageHandlerRuntimeHintsRegistrar.lambda$processAheadOfTime$0(MessageHandlerRuntimeHintsRegistrar.java:61)
        at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at org.axonframework.springboot.aot.MessageHandlerRuntimeHintsRegistrar.processAheadOfTime(MessageHandlerRuntimeHintsRegistrar.java:64)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.getContributions(BeanFactoryInitializationAotContributions.java:67)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:49)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:44)
        at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
        at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
        at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
        at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
@abuijze abuijze added this to the 4.10.1 milestone Sep 18, 2024
@abuijze
Copy link
Member Author

abuijze commented Nov 21, 2024

Addressed in #197

@abuijze abuijze closed this as completed Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants