NullPointerException instead of expected exception while creating an aggregate

While creating aggregate and if a runtime exception was thrown, instead of propagating that exception, a NullPointerException is being thrown.
This is the line that causing the issue - at org.axonframework.modelling.command.LockingRepository.prepareForCommit(

I think, the LockingRepository trying to assert aggregator’s state but aggregate itself not present because the exception was thrown while creating it.
How to get access to the actual exception?
Please help.


public User(CreateUserCommand command) {
// Some RuntimeException

CreateUserCommand command = new CreateUserCommand(username, firstName, lastName);
// Here instead of receiving that runtime exception we get NullPointerException

Hi Chaitanya,

I have tested this statement, by creating a simple Aggregate which in the constructor Command Handler throws an IllegalArgumentException (which extends from RuntimeException).
When throwing the exception, I correctly get the IllegalArgumentException instead of a NullPointerException as you have stated.

Thus, I think we need more information to deduce what the problem is, like:

  • Framework version you are

  • A complete stack trace
    Let’s try to figure out what the matter is in your application Chaitanya.