No EntityManager with actual transaction

Hello, i’m using axon 4.0.3 + Spring Boot 2 default configuration.

Having published event to the EventStore and waiting for it to be catched by @SagaEventHandler I received the following exception:

javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process ‘persist’ call
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke( ~[spring-orm-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at com.sun.proxy.$Proxy104.persist(Unknown Source) ~[na:na]
at$ForEachOp$OfRef.accept( ~[na:1.8.0_191]
at$3$1.accept( ~[na:1.8.0_191]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining( ~[na:1.8.0_191]
at ~[na:1.8.0_191]
at ~[na:1.8.0_191]
at$ForEachOp.evaluateSequential( ~[na:1.8.0_191]
at$ForEachOp$OfRef.evaluateSequential( ~[na:1.8.0_191]
at ~[na:1.8.0_191]
at ~[na:1.8.0_191]
at org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine.appendEvents( ~[axon-eventsourcing-4.0.3.jar:4.0.3]
at org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.appendEvents( ~[axon-eventsourcing-4.0.3.jar:4.0.3]

What additional configuration is required for the EventStore to handle this case.

PS. Adding @Transactional on the method solves this problem, but i dont understand why this is neccessary.

My code (the following endpoint is worked but the other one is not)

class TestAxonApplication

class UserId(val userId: String = IdentifierFactory.getInstance().generateIdentifier()) : Serializable

class TestCommand(@TargetAggregateIdentifier val userId: UserId)

class TestedEvent(val userId: UserId)

fun main(args: Array<String>) {

class Controller(var commandGateway: CommandGateway, var eventStore: EventStore) {

    fun done(): UserId? {
        return commandGateway.sendAndWait<UserId>(TestCommand(UserId()))

    fun failure() {


class User() {

    private lateinit var userId: UserId

    constructor(cmd: TestCommand) : this() {

    fun on(event: TestedEvent) {
        this.userId = event.userId


class MySaga {

    @SagaEventHandler(associationProperty = "userId")
    fun start(event: TestedEvent) {
        println("DONE ${event.userId.userId}")


Hi Sergey,

We noticed this issue of yours and pin pointed this to be an issue with the JpaEventStorageEngine.

Sadly, the JpaEventStorageEngine wasn’t performing the appendEvents(List<Object>) operation within a transaction of the configured TransactionManager.
This issue has been described by Allard here and resolved by me here.

The resolution is in Axon Framework release 4.1.1, so if you’d like to leverage our fix, you’d have to update your version.
If you update your version to 4.1.1, you’ll also be able to use the EventGateway instead of the EventBus directly to publish messages, as it gives you a cleaner API to do so.

If that’s not an option, I think you can either (1) add @Transactional to the method where you’re publishing the event or (2) pull in the TransactionManager in that controller yourself to execute the given operation in a Transaction.

Hope this helps!