Cannot request current Scope if none is active

Hello. I’m new to spring and to the Axon framework and I’m trying to wire up a small test project.

I’m getting a java.lang.IllegalStateException: Cannot request current Scope if none is active

My aggregate looks like this:

class Film {
lateinit var id: String
lateinit var name: String

fun on(event: FilmCreatedEvent) { = =


and my command handler like this:

class FilmCommandHandler (
private val filmRepository: FilmRepository
) {

fun on(command: CreateFilmCommand) {
Assert.hasLength(, “id missing”)
Assert.hasLength(, “missing name”)

val event = FilmCreatedEvent(,
AggregateLifecycle.appy(event) // ERROR

Can anyone point me in the right direction?

Tried doing AggregateLifecycle.apply instead AggregateLifecycle.appy ?

Aren’t they the same?

Hi Jack,

you can’t call apply() outside of your aggregate. Try moving your comand handler into your aggregate and removing the external command handler class.
Then, make sure the command handler that creates a new instance of your aggregate is actually a constructor. Commands that update an existing instance should be regular methods.

Hope this helps.


Thanks! I realized I was misunderstanding aggregates, all good now.