Axon Spring Boot App with two datasources saga pattern issue

Hello,

I have a spring boot application, and I have two data sources with the following configuration :

First data source configuration:

@Configuration
@ComponentScan({ "com.softilys.fraud.*" })
@EntityScan(basePackages = "com.softilys.fraud.entities.common")
@EnableJpaRepositories(basePackages = {"com.softilys.fraud.repository.common"}, entityManagerFactoryRef = "commonEntityManager", transactionManagerRef = "commonTransactionManager")
@ConditionalOnExpression("${datasource.common.enabled:true}")
@Slf4j
public class DatabaseCommonConfig {

  @Autowired
  private Environment env;

  @Bean
  ConfigurationProperties(prefix = "datasource.common")
  public DataSourceProperties ordersDataSourceProperties() {
    return new DataSourceProperties();
  }

  Bean(name = "cds")
  public HikariDataSource commonDataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    log.info("{}", env.getProperty("spring.application.name"));
    dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("datasource.driverClassName")));
    dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("spring.datasource.common.url")));
    dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("spring.datasource.common.username")));
    dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("spring.datasource.common.password")));

    final HikariDataSource hikariDataSource = new HikariDataSource();
    hikariDataSource.setDataSource(dataSource);
    hikariDataSource.setMaximumPoolSize(env.getProperty("datasource.common.pool.max-size", Integer.class, 10));
    hikariDataSource.setMinimumIdle(env.getProperty("datasource.common.pool.min-size", Integer.class, 5));
    hikariDataSource.setConnectionTimeout(env.getProperty("datasource.common.pool.connection-timeout", Integer.class, 30000));
    hikariDataSource.setKeepaliveTime(env.getProperty("datasource.common.pool.keepa-live-time", Integer.class, 120000));
    hikariDataSource.setIdleTimeout(30000);
    return hikariDataSource;
  }

  @Bean(name = "commonEntityManager")
  @Primary
  public LocalContainerEntityManagerFactoryBean commonEntityManager(final Qualifier("cds") HikariDataSource ds) {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(ds);
    em.setPackagesToScan("com.softilys.fraud.entities.common");

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    final HashMap<String, Object> properties = new HashMap<>();
    properties.put("hibernate.ddl-auto", "none");
    properties.put("hbm2ddl.auto", "none");
    properties.put("hibernate.dialect", env.getProperty("datasource.hibernate.dialect"));
    properties.put("hibernate.show_sql", env.getProperty("datasource.hibernate.show_sql"));
    properties.put("hibernate.enable_lazy_load_no_trans", true);

    em.setJpaPropertyMap(properties);

    return em;
  }

  @Bean(name = "commonTransactionManager")
  @DependsOn("commonEntityManager")
  @Primary
  public PlatformTransactionManager commonTransactionManager(EntityManagerFactory commonEntityManager) {
    return new JpaTransactionManager();
  }

  @Bean
  ConfigurationProperties(prefix = "spring.datasource.common.liquibase")
  public LiquibaseProperties commonLiquibaseProperties() {
    return new LiquibaseProperties();
  }

  @Bean("liquibaseCommon")
  public SpringLiquibase commonLiquibase() throws SQLException {
    return springLiquibase(commonDataSource(), commonLiquibaseProperties());
  }

  private static SpringLiquibase springLiquibase(DataSource dataSource, LiquibaseProperties properties) throws SQLException {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setDataSource(dataSource);
    liquibase.setChangeLog(properties.getChangeLog());
    liquibase.setContexts(properties.getContexts());
    liquibase.setDefaultSchema(properties.getDefaultSchema());
    liquibase.setDropFirst(properties.isDropFirst());
    liquibase.setShouldRun(properties.isEnabled());
    liquibase.setLabels(properties.getLabels());
    liquibase.setChangeLogParameters(properties.getParameters());
    liquibase.setClearCheckSums(true);
    liquibase.setRollbackFile(properties.getRollbackFile());
    try (Connection connect = dataSource.getConnection()) {
      log.debug("liquibase url:{}, changelog:{}", connect.getMetaData().getURL(), properties.getChangeLog());
    }
    return liquibase;
  }
}

Second data source configuration:

@Configuration
@ComponentScan({ "com.softilys.fraud.*" })
@EntityScan(basePackages = "com.softilys.fraud.entities.claim")
@EnableJpaRepositories(basePackages = "com.softilys.fraud.repository.claim", @entityManagerFactoryRef = "opticEntityManager", transactionManagerRef = "opticTransactionManager")
@Slf4j
@ConditionalOnExpression("${datasource.optic.enabled:true}")
public class DatabaseDeOpticConfig {

  @Autowired
  private Environment env;

  @Bean(name = "odsp")
  ConfigurationProperties(prefix = "datasource.optic")
  public DataSourceProperties ordersDataSourceProperties() {
    return new DataSourceProperties();
  }

  @Bean(name = "DATASOURCE_OPTIC")
  @Primary
  public HikariDataSource opticDataSource() {
    final DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("datasource.driverClassName")));
    dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("spring.datasource.optic.url")));
    dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("spring.datasource.optic.username")));
    dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("spring.datasource.optic.password")));

    final HikariDataSource hikariDataSource = new HikariDataSource();
    hikariDataSource.setDataSource(dataSource);
    hikariDataSource.setMaximumPoolSize(env.getProperty("datasource.optic.pool.max-size", Integer.class, 10));
    hikariDataSource.setMinimumIdle(env.getProperty("datasource.optic.pool.min-size", Integer.class, 5));
    hikariDataSource.setConnectionTimeout(env.getProperty("datasource.optic.pool.connection-timeout", Integer.class, 30000));
    hikariDataSource.setKeepaliveTime(env.getProperty("datasource.optic.pool.keepa-live-time", Integer.class, 120000));
    return hikariDataSource;
  }

  @Bean(name = "opticEntityManager")
  public LocalContainerEntityManagerFactoryBean opticEntityManager() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(opticDataSource());
    em.setPackagesToScan("com.softilys.fraud.entities.claim");

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    final HashMap<String, Object> properties = new HashMap<>();
    properties.put("hibernate.ddl-auto", "none");
    properties.put("hibernate.hbm2ddl.auto", "none");
    properties.put("hibernate.dialect", env.getProperty("datasource.hibernate.dialect"));
    properties.put("hibernate.show_sql", env.getProperty("datasource.hibernate.show_sql"));
    properties.put("hibernate.enable_lazy_load_no_trans", true);

    em.setJpaPropertyMap(properties);

    return em;
  }

  @Bean(name = "opticTransactionManager")
  @DependsOn("opticEntityManager")
  public PlatformTransactionManager opticTransactionManager() {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(opticEntityManager().getObject());
    return transactionManager;
  }

  @Bean
  @ConfigurationProperties(prefix = "spring.datasource.optic.liquibase")
  public LiquibaseProperties opticLiquibaseProperties() {
    return new LiquibaseProperties();
  }

  @Bean("liquibaseOptic")
  public SpringLiquibase opticLiquibase() throws SQLException {
    return springLiquibase(opticDataSource(), opticLiquibaseProperties());
  }

  private static SpringLiquibase springLiquibase(DataSource dataSource, LiquibaseProperties properties) throws SQLException {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setDataSource(dataSource);
    liquibase.setChangeLog(properties.getChangeLog());
    liquibase.setContexts(properties.getContexts());
    liquibase.setDefaultSchema(properties.getDefaultSchema());
    liquibase.setDropFirst(properties.isDropFirst());
    liquibase.setShouldRun(properties.isEnabled());
    liquibase.setLabels(properties.getLabels());
    liquibase.setChangeLogParameters(properties.getParameters());
    liquibase.setRollbackFile(properties.getRollbackFile());
    liquibase.setClearCheckSums(true);
    try (Connection connect = dataSource.getConnection()) {
      log.debug("liquibase url:{}, changelog:{}", connect.getMetaData().getURL(), properties.getChangeLog());
    }
    return liquibase;
  }
}

When I add the @Saga annotation, I get this error when trying to start my application:

java.util.concurrent.ExecutionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sagaStore' defined in class path resource [org/axonframework/springboot/autoconfig/JpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.modelling.saga.repository.jpa.JpaSagaStore]: Factory method 'sagaStore' threw exception; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395) ~[na:na]
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2022) ~[na:na]
	at org.axonframework.config.DefaultConfigurer.invokeLifecycleHandlers(DefaultConfigurer.java:858) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.DefaultConfigurer.invokeStartHandlers(DefaultConfigurer.java:802) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.DefaultConfigurer$ConfigurationImpl.start(DefaultConfigurer.java:953) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.spring.config.SpringAxonConfiguration.start(SpringAxonConfiguration.java:76) ~[axon-spring-4.6.1.jar:4.6.1]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.25.jar:5.3.25]
	at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.25.jar:5.3.25]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.9.jar:2.7.9]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.9.jar:2.7.9]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.9.jar:2.7.9]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.9.jar:2.7.9]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.9.jar:2.7.9]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.9.jar:2.7.9]
	at com.softilys.fraud.Application.main(Application.java:16) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sagaStore' defined in class path resource [org/axonframework/springboot/autoconfig/JpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.modelling.saga.repository.jpa.JpaSagaStore]: Factory method 'sagaStore' threw exception; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.axonframework.spring.config.SpringConfigurer$ComponentLocator.findBean(SpringConfigurer.java:67) ~[axon-spring-4.6.1.jar:4.6.1]
	at org.axonframework.spring.config.SpringConfigurer.defaultComponent(SpringConfigurer.java:50) ~[axon-spring-4.6.1.jar:4.6.1]
	at org.axonframework.config.DefaultConfigurer$ConfigurationImpl.lambda$null$0(DefaultConfigurer.java:930) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.DefaultConfigurer$ConfigurationImpl.getComponent(DefaultConfigurer.java:931) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.EventProcessingModule.lambda$new$14(EventProcessingModule.java:159) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.EventProcessingModule.sagaStore(EventProcessingModule.java:443) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.SagaConfigurer.lambda$new$0(SagaConfigurer.java:49) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.SagaConfigurer$SagaConfigurationImpl.lambda$initialize$1(SagaConfigurer.java:214) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.SagaConfigurer$SagaConfigurationImpl.lambda$initialize$2(SagaConfigurer.java:228) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.SagaConfigurer$SagaConfigurationImpl.manager(SagaConfigurer.java:164) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.EventProcessingModule.lambda$null$42(EventProcessingModule.java:339) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.EventProcessingModule.lambda$buildEventProcessor$44(EventProcessingModule.java:354) ~[axon-configuration-4.6.1.jar:4.6.1]
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
	at org.axonframework.config.EventProcessingModule.buildEventProcessor(EventProcessingModule.java:355) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.EventProcessingModule.lambda$null$26(EventProcessingModule.java:219) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.6.1.jar:4.6.1]
	at java.base/java.util.HashMap$Values.forEach(HashMap.java:977) ~[na:na]
	at org.axonframework.config.EventProcessingModule.initializeProcessors(EventProcessingModule.java:223) ~[axon-configuration-4.6.1.jar:4.6.1]
	at org.axonframework.config.LifecycleOperations.lambda$onStart$0(LifecycleOperations.java:62) ~[axon-configuration-4.6.1.jar:4.6.1]
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
	at java.base/java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:558) ~[na:na]
	at org.axonframework.config.DefaultConfigurer.invokeLifecycleHandlers(DefaultConfigurer.java:856) ~[axon-configuration-4.6.1.jar:4.6.1]
	... 18 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.modelling.saga.repository.jpa.JpaSagaStore]: Factory method 'sagaStore' threw exception; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.25.jar:5.3.25]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.25.jar:5.3.25]
	... 65 common frames omitted
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:362) ~[spring-orm-5.3.25.jar:5.3.25]
	at com.sun.proxy.$Proxy150.createQuery(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:311) ~[spring-orm-5.3.25.jar:5.3.25]
	at com.sun.proxy.$Proxy150.createQuery(Unknown Source) ~[na:na]
	at org.axonframework.modelling.saga.repository.jpa.JpaSagaStore.addNamedQueriesTo(JpaSagaStore.java:132) ~[axon-modelling-4.6.1.jar:4.6.1]
	at org.axonframework.modelling.saga.repository.jpa.JpaSagaStore.<init>(JpaSagaStore.java:115) ~[axon-modelling-4.6.1.jar:4.6.1]
	at org.axonframework.modelling.saga.repository.jpa.JpaSagaStore$Builder.build(JpaSagaStore.java:397) ~[axon-modelling-4.6.1.jar:4.6.1]
	at org.axonframework.springboot.autoconfig.JpaAutoConfiguration.sagaStore(JpaAutoConfiguration.java:76) ~[axon-spring-boot-autoconfigure-4.6.1.jar:4.6.1]
	at org.axonframework.springboot.autoconfig.JpaAutoConfiguration$$EnhancerBySpringCGLIB$$4ac9c1f0.CGLIB$sagaStore$2(<generated>) ~[axon-spring-boot-autoconfigure-4.6.1.jar:4.6.1]
	at org.axonframework.springboot.autoconfig.JpaAutoConfiguration$$EnhancerBySpringCGLIB$$4ac9c1f0$$FastClassBySpringCGLIB$$b778c00a.invoke(<generated>) ~[axon-spring-boot-autoconfigure-4.6.1.jar:4.6.1]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.25.jar:5.3.25]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.25.jar:5.3.25]
	at org.axonframework.springboot.autoconfig.JpaAutoConfiguration$$EnhancerBySpringCGLIB$$4ac9c1f0.sagaStore(<generated>) ~[axon-spring-boot-autoconfigure-4.6.1.jar:4.6.1]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.25.jar:5.3.25]
	... 66 common frames omitted
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
	at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:220) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:112) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:73) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:162) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:636) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:748) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	... 93 common frames omitted
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped
	at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:170) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:77) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:334) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3782) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3671) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:746) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:602) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:339) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:287) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:276) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:192) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	... 99 common frames omitted

Thanks for your help in advance.

Hi @khalil-BG, and welcome to the forum!

Firstly, I have edited your post (I assume you don’t mind) to:

  1. Use markdown semantics for the code snippets,
  2. drop all the import statements, as they obstruct the important parts, and
  3. to use articles and capitals for clarity.

For the future, I would recommend you do the same.
It makes it so that other readers are better capable of grasping the problem you’re facing instead of being required to comprehend the block of text dropped on them.

Secondly, concerning your predicament, although the top exception makes it seem you’re dealing with an Axon Framework predicament, diving into the exception we see the following:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: SagaEntry is not mapped
	at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:170) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
	at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:77) ~
...

This exception means that your Axon Framework entities are not mapped to the EntityManager configured for the SagaStore.
As I am not certain how you are defining the shared data sources to the Axon Framework infrastructure components, I am not certain which of the two you need to adjust.
Nonetheless, I would suggest to play around by adding the packages containing Axon’s JPA entities, which are:

  • org.axonframework.eventhandling.tokenstore - for TrackingTokens
  • org.axonframework.eventhandling.deadletter.jpa - for DeadLetters
  • org.axonframework.modelling.saga.repository.jpa - for sagas and association value entries
  • org.axonframework.eventsourcing.eventstore.jpa - for events and snapshots

I hope this helps you further, @khalil-BG!!