Axon 3.2.2 to 3.3.2 upgrade issues on JPA entity update


In my project we are using AXON 3.2.2 .After upgrading to latest stable 3.3.2 , existing entity update and event firing is not working and below exception is throwing

As per my understanding a new feature 'scope ’ need to added for messaging on latest release .please help me to understand how we can configure scope feature in entity for update along with event firing

java.lang.IllegalStateException: Cannot request current Scope if none is active
at org.axonframework.messaging.Scope.getCurrentScope( ~[axon-core-3.3.2.jar:3.3.2]
at org.axonframework.commandhandling.model.AggregateLifecycle.getInstance( ~[axon-core-3.3.2.jar:3.3.2]
at org.axonframework.commandhandling.model.AggregateLifecycle.apply( ~[axon-core-3.3.2.jar:3.3.2]
at com.acme.ecom.product.model.Product.depreciateStock( ~[classes/:na]


Hi Arun,

You shouldn’t have to start a Scope yourself, the framework will take care of that for you.

If you use the regular Repository<Product> interface instead of using the repository which gives you the LockAwareAggregate, you should be fine.

The Aggregate<Product> you’d pull from that has a invoke(Function<T, R> invocation) function with which you can call your depreciateStock(), which the framework will correctly wrap in a Scope.

Apart from that, I’d suggest to have your @CommandHandler annotated functions on the Aggregate directly instead of in a separate component, as the format you’re using more so resembles Axon 1 than 2 or 3. Additionally, don’t forget to use the @AggregateRoot (or @Aggregate if you’re on Spring) annotation on your Aggregate class.

Hope this helps!