Axon is trying to persist an aggregate

1,704 views
Skip to first unread message

jnemecz

unread,
Jul 28, 2018, 4:04:05 PM7/28/18
to Axon Framework Users
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?

Allard Buijze

unread,
Jul 29, 2018, 9:40:31 AM7/29/18
to axonfr...@googlegroups.com
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
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Allard Buijze
CTO

E: allard...@axoniq.io
T: +31 6 34 73 99 89

jnemecz

unread,
Jul 29, 2018, 10:11:36 AM7/29/18
to Axon Framework Users
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):

Allard Buijze

unread,
Aug 2, 2018, 10:30:53 AM8/2/18
to axonfr...@googlegroups.com
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

Suresh Adapa

unread,
Apr 21, 2020, 7:06:29 AM4/21/20
to Axon Framework Users
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

Suresh Adapa

unread,
Apr 21, 2020, 11:51:50 AM4/21/20
to Axon Framework Users

My mistake, Ops there was recursive ComandHandler which i removed. Problem solved.Thanks.
Reply all
Reply to author
Forward
0 new messages