Unknown entity: DomainEventEntry

Hello.

I’m trying to follow webinars and create simple Spring app using Axon.

I’m have

  • download Spring app template,
  • add dependency for org.axonframework:axon-spring:3.0.7,
  • setup JPA,
  • add spring controller, one aggregate with command handler method, one command, and one event
  • add annotations

@EntityScan(basePackageClasses = DomainEventEntry.class)
@EnableAxon

to application class.

Everything works well - command dispatched to aggregate, event is created… But it is not persisted. I got a WARN:

o.a.c.gateway.DefaultCommandGateway : Command ‘com.example.axon2.domain.CreateProfile’ resulted in org.axonframework.eventsourcing.eventstore.EventStoreException(An event for aggregate [432ec66d-3981-46af-86d2-dba2bc793db1] at sequence [0] could not be persisted)

And original exception from Hibernate is:

org.hibernate.MappingException: Unknown entity: org.axonframework.eventsourcing.eventstore.jpa.DomainEventEntry

I have a feeling that I missed something very small, and something really simple ).

What could be an issue?

Regards,
Stepan.

Hi Stepan,

the webinars on the Trifork channel are based on a release candidate version of Axon. The final release has had some major improvements.
First of all, if you include the Axon Spring Boot Starter module, you don’t need to specify @EnableAxon anymore. Neither should you need to specify any @EntityScan. It should work just right out of the box.

In your case, do you have multiple @EntityScan annotations in your application? It seems that different annotations can overwrite eachother’s configuration. If you don’t specify any at all, Axon will automatically register its entities with the EntityManager. Otherwise, you need to explicitly do so in a single @EntityScan, apparently.

We are planning on recording a new webinar on December 6th, at 4PM CET. We will be publishing this formally, soon.

Hope this helps.
Cheers,

Allard

Hi, Allard.

When I’m using Axon Spring Boot Starter - I got an exception about Sagas (you can find another topic about that issue here in group). As far as I’m very motivated to use Axon - I’m just trying to find out any way how to use it ;).

There is only one place where I use @EntityScan annotation:

Hi Stepan,

I just replied on the other thread, linking to the solution I did at JavaDay Ukraine 2017: https://github.com/smcvb/javaday17/tree/solution

Aside from that probably providing you with the required solution, I can tell you that if you’re using the axon-spring-boot-starter dependency, there is no need to add the @EnableAxon annotation to your application.
Additionally, you’ll also not need to specify the axon-spring dependency explicitly if you’re using the axon-spring-boot-starter.

Lastly, in the solution I referenced to I’m not using the @EntityScan annotation.

I hope it might give you some guidance and as I shared in my previous post, sorry that I cant give you the exact solution to the exceptions you’re seeing as it slipped my mind.
I’d however say it’s probably a project set up problem rather than an Axon specific issue.

Hope this helps!

Cheers,

Steven

Did you include the Spring Boot Starter for Data JPA?

Other than that dependency, you don’t need any configuration at all to make it work. Just annotate your aggregate root with @Aggregate, and you’re ready to go.

You can also check out our quickstart: https://github.com/AxonIQ/axon-quick-start
The scaling-out module has a working application.

Cheers,

Allard