Why do you get this error in general terms?
I am working on replacing my PoC InMemoryEventStore and query models stored in HashMap to JPA versions, so my program can survive restart
In the debugger it looks like Axon finds the Spring TransactionManager and gets the UoW bound to a transaction.
I get this exception when dispatching the command:
java.lang.IllegalStateException: Could not clear this UnitOfWork. It is not the active one.
at org.axonframework.messaging.unitofwork.CurrentUnitOfWork.clear(CurrentUnitOfWork.java:139)
at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.commit(AbstractUnitOfWork.java:75)
at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:80)
at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:156)
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:127)
at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:91)
at org.axonframework.commandhandling.gateway.AbstractCommandGateway.send(AbstractCommandGateway.java:79)
at org.axonframework.commandhandling.gateway.DefaultCommandGateway.send(DefaultCommandGateway.java:95)
at org.axonframework.commandhandling.gateway.DefaultCommandGateway.sendAndWait(DefaultCommandGateway.java:113)
at dk.bec.etl.simulator.rest.DemoRestService.anmeld(DemoRestService.java:108)