-
Notifications
You must be signed in to change notification settings - Fork 9
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
Scope is not active or entity cannot be found when using kotlin extension for "applyEvent" #286
Comments
One side questionWithin the entity, there is the |
First and foremost, as you're dealing with a Kotlin Extension predicament, your issue should've been constructed under the https://github.com/AxonFramework/extension-kotlin. Secondly, I find it odd you're faced with this predicament. fun applyEvent(payload: Any): ApplyMore = AggregateLifecycle.apply(payload) We can see it literally invokes |
I have just written a minimal test case using the To validate further, I'll construct a sample project using our initializr to see if I can replay the behavior you're seeing. I do note two other pointers from your issues, which I'd like to reply to. First pointer
As nothing has recently changed around the Second pointer
I believe the |
So, as promised, I've also made a minimal sample Spring Boot app. For clarity, the aggregate looks like this: @Aggregate
class MyAggregate {
@AggregateIdentifier
private lateinit var id: String
constructor()
@CommandHandler
@CreationPolicy(AggregateCreationPolicy.ALWAYS)
fun handle(cmd: ExampleCommand) {
val event = ExampleEvent(cmd.id)
if (cmd.extensionFunction) {
applyEvent(event)
print("extension!")
} else {
AggregateLifecycle.apply(event)
print("none extension!")
}
}
@EventSourcingHandler
fun on(event: ExampleEvent) {
this.id = event.id
}
}
class ExampleCommand(@TargetAggregateIdentifier val id: String, val extensionFunction: Boolean = false)
class ExampleEvent(val id: String) Although it's smaller than your sample, it should trigger similar behavior, I'd assume. Can you share a minimal reproducible project showcasing the issue you're facing? |
Thank you for going through the issue, I will try to setup a project with reproducible issue. In pom, I have
|
@smcvb I did reproduce it https://github.com/Blackdread/axon-event-apply-error |
For some weird reason, it seems to be What can Axon do? |
Great find, @Blackdread! In the past, we actually had to make a minor addition to Axon Framework and the extensions to accommodate Spring Boot Devtools. I do find it odd this surfaces for the |
I have just added a pull request adding the behavior to the Kotlin Extension. I have not set it as a bug, though, as I think it's more a form of undocumented missing support. I assume you're fine with disabling devtools for the time being as a workaround? |
I am fine with disabling it for now. |
…vtools-support [#286] Add `spring-boot-devtools` support
Closing this issue, as the Spring Boot Devtools support has been introduced by PR #287. |
Basic information
Steps to reproduce
Expected behaviour
We should be able to use
applyEvent
fromkotlin-extension
Actual behaviour
An error is thrown within the aggregate.
For info: Aggregate is fully tested with
AggregateTestFixture
for root and entities and for all commands/events, no errors.Root aggregate
In case of root aggregate, I get error
Cannot request current Scope if none is active
, using the debugger it is thrown fromorg.axonframework.messaging.Scope
Entity of root aggregate
In case of entity of root aggregate, I get error
Cannot request current Scope if none is active
, using the debugger it is thrown fromorg.axonframework.messaging.Scope
or errorAggregate cannot handle command ... as there is no entity instance within the aggregate to forward it to
.The code for @EntityID is correct as it works in
AggregateTestFixture
.Solution found
As strange as it seems but errors disappear if replace
applyEvent(...)
byAggregateLifecycle.apply(...)
.The only reason I can think of is that in the BOM, not all dependencies have the same axon framework version and for some reason something is broken in some version.
The text was updated successfully, but these errors were encountered: