It means you’re trying to apply an event whilst you don’t have a UnitOfWork.
More code specific, you’re calling either AggregateLifecycle.apply(), AggregateLifecycle.isLive() or 'AggregateLifecycle.markDeleted()` whilst you don’t have a UnitOfWork started, which probably means you’re calling one of those functions outside of an aggregate.
However, a code example would work better to tell you what’s going wrong.
Could you share a snippit of code of the ‘command and event handlers defined’?
What Allard means to ask is if you’re wiring the Aggregate Repository yourself to retrieve an aggregate to make it handle commands or if you let Axon do all the work.
From your short snippet however I think you’re trying to create the aggregate yourself, so ‘invoking directly’ would have been the case.
You’re however not inclined to call the constructor of an aggregate directly at all, the Repository implementation will take care of that.
You can just publish the CreateProfile command on the CommandBus (or through the CommandGateway) and Axon will know to call the command handling constructor of the Profile aggregate.
Internally it will then create the UnitOfWork, which will start the Aggregates Lifecycle, thus solving the exception you’re getting.
If this doesn’t solve your issue, please be more specific of your Axon application configuration and the version you’re using.