Hello,
I am using Axon 4.X
My Structure looks like this
`
- AggregatePackage
- Aggregate1
- CommandHandlerPackage
- CommandHandler (Aggregate1)
`
When my command handler is in separate package and class
`
java.lang.IllegalStateException: Cannot request current Scope if none is active
at org.axonframework.messaging.Scope.getCurrentScope(Scope.java:53) ~[axon-messaging-4.0.3.jar:4.0.3]
at org.axonframework.modelling.command.AggregateLifecycle.getInstance(AggregateLifecycle.java:124) ~[axon-modelling-4.0.3.jar:4.0.3]
at org.axonframework.modelling.command.AggregateLifecycle.apply(AggregateLifecycle.java:62) ~[axon-modelling-4.0.3.jar:4.0.3]
`
Reading a lot of documentation and previous posts I see that it is recommended to have the @CommandHandler inside the aggregate class for commands that create the aggregate instance for e.g CreateProduct but we can have the commands outside the aggregate class for commands that are applied on an existing aggregate for e.g UpdateProduct
When I worked with Axon 3.X I remember to have all the commands outside the aggregate class and it worked perfectly fine.
Please advice.