Axon is trying to persist an aggregate

Hello,

I’m trying Axon for the first time and have a rough time with my very basic Axon app (Spring Boot). I have no configuration for Axon.

Controller:


@PostMapping
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void create(@RequestBody @Valid CreateTaskRequest request) {
 UUID id = UUID.randomUUID();
 commandGateway.send(new CreateTaskCommand(id, request.getTitle()));
}

This is my aggregate that acts as a command handler and events sourcing handler:

`

@Aggregate

public class Task {

private static final long serialVersionUID = -5977984483620451665L;

private static Logger LOGGER = LogManager.getLogger(ApiController.class);

@AggregateIdentifier
private UUID id;

@CommandHandler
public Task(CreateTaskCommand command) {
apply(new TaskCreatedEvent(command.getId(), command.getTitle(), command.getCreatedAt()));
}

@EventSourcingHandler
void on(TaskCreatedEvent event) {
this.id = event.getId();
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}

}

`

And I get this exception:

21:51:22.591 [http-nio-8080-exec-1] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 42P01 21:51:22.591 [http-nio-8080-exec-1] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: relation "hibernate_sequence" does not exist Pozice: 17 21:51:22.597 [http-nio-8080-exec-1] WARN org.axonframework.commandhandling.gateway.DefaultCommandGateway - Command 'sandbox.CreateTaskCommand' resulted in org.axonframework.eventsourcing.eventstore.EventStoreException(An event for aggregate [a335b9ca-fe8d-49e0-aa90-4fa76ddbb450] at sequence [0] could not be persisted)

Even I don’t try to persist any entity / aggregate manually - why is Axon trying to get some sequence value and why and where is trying to persist?

What did I do wrong?

Axon is trying to persist an event in the event store. But the tables (in this case the sequence is the first thing it will probably look for) aren’t created.
Do you have (hibernate) ddl configured?

Allard

Hi Allard,

I have Hibernate entity that I wan to save manually in task entry event handler - I was misunderstood the exception is related to my entity. But as far as I understood you, you’re speaking about events - no, I haven’t created any entity related tables till now.

Is there some example how should these events tables look like and how should be anotated?

Thanks.

Dne neděle 29. července 2018 15:40:31 UTC+2 Allard Buijze napsal(a):

Hi,

when using Spring Boot, Axon will automatically register the entities as default entities, which will ensure Spring Boot will have them registered with your JPA provider. If you provide any @EntityScan manually, you must also include the packages that contain the Axon entities. In your case, the exception doesn’t seem to suggest that.

If you use an in-memory database, Spring Boot will automatically enable ddl generation. If you use a “regular” database, you must enable that yourself in application.properties.

spring.jpa.hibernate.ddl-auto=update

Cheers,

Allard

Hi,

issue-3.PNG

I am using openjdk11 and trying to build Springboot + CRQS axon application with H2 database.
Some how the ComplableFuture is not working and appears to have some kind of leaks/…?

issue-2.PNG

issue-1.PNG

issue-1.PNG

My mistake, Ops there was recursive ComandHandler which i removed. Problem solved.Thanks.