Help about Saga test and Spring Configuration

I want to use the spring configuration class to inject the commandGateway inside a saga instance.
I set as @Autowired the CommandGateway transient field in Saga class, but my test fails due to a NullPointerException. The CommandGateway is not injected.

Do you see what I can’t see? Maybe it’s something missing in Axon configuration properties that gives me this “I don’t know what happen but it happens, sorry” exception? :smiley:

Here’s the Saga code:


public class EnrollmentSaga extends AbstractAnnotatedSaga {
private boolean personalInfoChanged = false;

private transient CommandGateway commandGateway;

@SagaEventHandler(associationProperty = “enrollmentId”)
public void handle(final EnrollmentStartedEvent event) {

associateWith(“employeeId”, event.getEmployeeId().toString());

commandGateway.send(new RegisterPersonalInfo(event.getEmployeeId(), event.getPerson()));


Here’s the Test code:


public void shouldEnrollANewEmployee() {
val employeeId = UUID.randomUUID();
val hiringDate = DateTime.parse(“2015-09-05T12:00”);
val enrollmentId = new EnrollmentId(UUID.randomUUID());

final AnnotatedSagaTestFixture fixture = new AnnotatedSagaTestFixture(EnrollmentSaga.class);
// fixture.registerCommandGateway(CommandGateway.class, commandGateway);
.whenPublishingA(new EnrollmentStartedEvent(enrollmentId, employeeId,

// or, to match against the payload of a Command Message only
new RegisterPersonalInfo(employeeId, person)))));


Thank you very much,


unfortunately, the Saga fixtures don’t work using Spring dependency injection annotations (yet). To be able to inject the gateway, you’ll need a setter that accepts the Gateway as parameter.