Issue in migration to 4.7 or 4.8

I am are trying to use mongo as eventstore Axon config :
@Configuration
public class AxonConfig {

// The EmbeddedEventStore delegates actual storage and retrieval of events to an EventStorageEngine.
@Bean
public EventStore eventStore(EventStorageEngine storageEngine,
                             GlobalMetricRegistry metricRegistry) {
    return EmbeddedEventStore.builder()
                             .storageEngine(storageEngine)
                             .messageMonitor(metricRegistry.registerEventBus("eventStore"))
                             .spanFactory(spanFactory)
                             // ...
                             .build();
}

// The MongoEventStorageEngine stores each event in a separate MongoDB document.
@Bean
public EventStorageEngine storageEngine(MongoDatabaseFactory factory,
                                        TransactionManager transactionManager) {
    return MongoEventStorageEngine.builder()
                                  .mongoTemplate(SpringMongoTemplate.builder()
                                                                    .factory(factory)
                                                                    .build())
                                  .transactionManager(transactionManager)
                                  // ...
                                  .build();
}

}

SpringMongoTemplate Not found
spanFactory not found

Maven :

        <groupId>org.axonframework</groupId>

        <artifactId>axon-spring-boot-starter</artifactId>

        <exclusions>

            <exclusion>

                <groupId>org.axonframework</groupId>

                <artifactId>axon-server-connector</artifactId>

            </exclusion>

        </exclusions>

        <version>4.8.0</version>

    </dependency>

    <dependency>

        <groupId>org.axonframework.extensions.springcloud</groupId>

        <artifactId>axon-springcloud-spring-boot-starter</artifactId>

        <version>4.8.0</version>

    </dependency>

    <dependency>

        <groupId>org.axonframework.extensions.mongo</groupId>

        <artifactId>axon-mongo</artifactId>

        <version>4.8.0</version>

    </dependency>

    <dependency>

        <groupId>org.axonframework</groupId>

        <artifactId>axon-metrics</artifactId>

        <version>4.8.0</version>

    </dependency>
      <dependency>

        <groupId>org.axonframework.extensions.jgroups</groupId>

        <artifactId>axon-jgroups-spring-boot-starter</artifactId>

        <version>4.8.0</version>

    </dependency>

Hi Viha,

I’m not sure where you wire the spanFactory? It seems like if you would add it to the argument, it would get auto-wired. Please note that instead, or in addition to disabling the connector, you could set axon.axonserver.enabled=false to disable any auto-configuration for Axon Server. Please also note that using Mongo as the event store can cause several problems in the long run.

Thanks,

axon.axonserver.enabled=false : done
spanFactory worked
Thanks for your warning about for mongo as event store ( unfortunately at this stage we need quick solution)

SpringMongoTemplate not found still an issue

Maybe you have spring data included, which might skip all the auto-wiring for Mongo.
Adding something similar to what’s in the mongo extension itself:

    @Bean
    @ConditionalOnMissingBean
    public MongoTemplate axonMongoTemplate(MongoDatabaseFactory factory) {
        String databaseName = axonMongoProperties.getDatabaseName();
        if (isNull(databaseName)) {
            return SpringMongoTemplate.builder()
                                      .factory(factory)
                                      .build();
        } else {
            return SpringMongoTemplate.builder()
                                      .factory(factory)
                                      .databaseName(databaseName)
                                      .build();
        }
    }

Should solve the remaining issue.
Seems also it should be MongoTemplate and not SpringMongoTemplate.

Thanks for your reply

  1. SpringMongoTemplate is not part of any jar is there any specific dependency for this

  2. I tried with different options of AxonConfig

    2.1

     @Bean
     public MongoClient mongo() {
     final ConnectionString connectionString = new ConnectionString("mongodb://" + "pass" + ":" + "pass"
     		+ "@" + "localhost" + ":" + "27017" + "/" + "db");
     final MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
     		.applyConnectionString(connectionString).build();
     return MongoClients.create(mongoClientSettings);
    }
      @Bean
    public MongoDatabaseFactory mongoFactory() {
     SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(mongo(), 
     		"db");
     return factory;
    }
     @Bean
    public TokenStore tokenStore(Serializer serializer) {
     return MongoTokenStore.builder().mongoTemplate(axonMongoTemplate(mongoFactory())).serializer(serializer).build();
    }
     @Bean
     public EventStore eventStore(EventStorageEngine storageEngine,
                                  GlobalMetricRegistry metricRegistry,SpanFactory spanFactory) {        
     	return EmbeddedEventStore.builder()
                                  .storageEngine(storageEngine)
                                  .messageMonitor(metricRegistry.registerEventBus("eventStore"))
                                  .spanFactory(spanFactory)
                                  .build();
     }
     @Bean("eventStorageEngine")
     public EventStorageEngine storageEngine(
                                             TransactionManager transactionManager
                                             ) {
         return MongoEventStorageEngine.builder().
         		eventSerializer(
         		XStreamSerializer.builder().xStream(
         				SecureXStreamSerializer.get().getXStream()).build())
         				.snapshotSerializer(XStreamSerializer.builder().
         				xStream(SecureXStreamSerializer.get().getXStream()).build()).
                                       mongoTemplate(axonMongoTemplate(mongoFactory()))	                                                                        
                                       .transactionManager(transactionManager)                                    
                                       .build();
     }	    
     @Bean
     //@ConditionalOnMissingBean
     public MongoTemplate axonMongoTemplate(MongoDatabaseFactory factory) {
         String databaseName = "db";	        
             return SpringMongoTemplate.builder()
                                       .factory(factory)
                                       .databaseName(databaseName)
                                       .build();	        
     }	    
    @Bean
    public Supplier<Flux<String>> output() {
     return () -> {
     	return Flux.just("OK");
     };
    } 
    

2.2

 @Bean
public MongoTemplate axonMongoTemplate() {
	return DefaultMongoTemplate.builder().mongoDatabase(mongo(), "catalog").build();
}

@Bean
public MongoClient mongo() {
	final ConnectionString connectionString = new ConnectionString(
			"mongodb://" + "pass" + ":" + "pass" + "@" + "localhost" + ":" + "27017" + "/" + "db");
	final MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
			.applyConnectionString(connectionString).build();
	return MongoClients.create(mongoClientSettings);
}

@Bean
public MongoDatabaseFactory mongoFactory() {

	SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(mongo(), "db");
	return factory;
}

@Bean
public TokenStore tokenStore(Serializer serializer) {
	return MongoTokenStore.builder().mongoTemplate(axonMongoTemplate()).serializer(serializer).build();
}

@Bean
public EventStore eventStore(EventStorageEngine storageEngine, GlobalMetricRegistry metricRegistry,
		SpanFactory spanFactory) {

	return EmbeddedEventStore.builder().storageEngine(storageEngine)
			.messageMonitor(metricRegistry.registerEventBus("eventStore")).spanFactory(spanFactory).build();
}

@Bean("eventStorageEngine")
public EventStorageEngine storageEngine(TransactionManager transactionManager) {
	return MongoEventStorageEngine.builder()
			.eventSerializer(
					XStreamSerializer.builder().xStream(SecureXStreamSerializer.get().getXStream()).build())
			.snapshotSerializer(
					XStreamSerializer.builder().xStream(SecureXStreamSerializer.get().getXStream()).build())
			.mongoTemplate(DefaultMongoTemplate.builder().mongoDatabase(mongo()).build())
			.transactionManager(transactionManager)

			.build();
}

@Bean
public Supplier<Flux<String>> output() {
	return () -> {
		return Flux.just("OK");
	};
}

2.3

@Bean
public MongoTemplate axonMongoTemplate() {
	return DefaultMongoTemplate.builder().mongoDatabase(mongo(), "catalog").build();
}

@Bean
public MongoClient mongo() {
	final ConnectionString connectionString = new ConnectionString(
			"mongodb://" + "pass" + ":" + "pass" + "@" + "localhost" + ":" + "27017" + "/" + "db");
	final MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
			.applyConnectionString(connectionString).build();
	return MongoClients.create(mongoClientSettings);
}

@Bean
public MongoDatabaseFactory mongoFactory() {

	SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(mongo(), "db");
	return factory;
}

@Bean
public TokenStore tokenStore(Serializer serializer) {
	return MongoTokenStore.builder().mongoTemplate(axonMongoTemplate()).serializer(serializer).build();
}

@Bean
public EventStore eventStore(EventStorageEngine storageEngine, GlobalMetricRegistry metricRegistry,
		SpanFactory spanFactory) {

	return EmbeddedEventStore.builder().storageEngine(storageEngine)
			.messageMonitor(metricRegistry.registerEventBus("eventStore")).spanFactory(spanFactory).build();
}

@Bean("eventStorageEngine")
public EventStorageEngine storageEngine(TransactionManager transactionManager) {
	return MongoEventStorageEngine.builder()
			.mongoTemplate(SpringMongoTemplate.builder().factory(mongoFactory()).build())
			.transactionManager(transactionManager)

			.build();
}

@Bean
public Supplier<Flux<String>> output() {
	return () -> {
		return Flux.just("OK");
	};
}

in all these option same exception :

Cannot reuse aggregate identifier [e3818e62-a577-4067-914e-778c8e938dd4] to create aggregate [StateMachineAggregate] since identifiers need to be unique.

 detail exception in next comment

org.axonframework.eventsourcing.eventstore.EventStoreException: Cannot reuse aggregate identifier [e3818e62-a577-4067-914e-778c8e938dd4] to create aggregate [StateMachineAggregate] since identifiers need to be unique.
** at org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.handlePersistenceException(AbstractEventStorageEngine.java:127) ~[axon-eventsourcing-4.7.0.jar:4.7.0]**
** at org.axonframework.extensions.mongo.eventsourcing.eventstore.MongoEventStorageEngine.appendEvents(MongoEventStorageEngine.java:125) ~[axon-mongo-4.8.0.jar:4.8.0]**
** at org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.appendEvents(AbstractEventStorageEngine.java:105) ~[axon-eventsourcing-4.7.0.jar:4.7.0]**
** at org.axonframework.eventsourcing.eventstore.AbstractEventStore.prepareCommit(AbstractEventStore.java:66) ~[axon-eventsourcing-4.7.0.jar:4.7.0]**
** at org.axonframework.eventhandling.AbstractEventBus.doWithEvents(AbstractEventBus.java:246) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.eventhandling.AbstractEventBus.lambda$null$14(AbstractEventBus.java:168) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.tracing.Span.runConsumer(Span.java:193) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.tracing.Span.lambda$wrapConsumer$4(Span.java:210) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.MessageProcessingContext.notifyHandlers(MessageProcessingContext.java:72) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.notifyHandlers(DefaultUnitOfWork.java:109) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.changePhase(AbstractUnitOfWork.java:236) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.commitAsRoot(AbstractUnitOfWork.java:87) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.commit(AbstractUnitOfWork.java:75) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:95) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.SimpleCommandBus.lambda$handle$4(SimpleCommandBus.java:201) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.tracing.Span.runSupplier(Span.java:163) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:192) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:165) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.SimpleCommandBus.lambda$dispatch$2(SimpleCommandBus.java:131) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.tracing.Span.run(Span.java:101) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:125) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.gateway.AbstractCommandGateway.send(AbstractCommandGateway.java:76) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.gateway.DefaultCommandGateway.send(DefaultCommandGateway.java:83) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.commandhandling.gateway.DefaultCommandGateway.sendAndWait(DefaultCommandGateway.java:100) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at com.orange.disco.processflow.service.impl.ProcessFlowCommandServiceImpl.createProcessFlow(ProcessFlowCommandServiceImpl.java:52) ~[classes/:na]**
** at com.orange.disco.processflow.controller.impl.ProcessFlowCommandControllerImpl.createProcessFlow(ProcessFlowCommandControllerImpl.java:44) ~[classes/:na]**
** at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]**
** at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na]**
** at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:547) ~[jakarta.servlet-api-6.0.0.jar:6.0.0]**
** at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.0.12.jar:6.0.12]**
** at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614) ~[jakarta.servlet-api-6.0.0.jar:6.0.0]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.springframework.security.web.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$FilterObservation$SimpleFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:479) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$AroundFilterObservation$SimpleAroundFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:340) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator.lambda$wrapSecured$0(ObservationFilterChainDecorator.java:82) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:128) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:107) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:93) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:82) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:69) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:62) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$AroundFilterObservation$SimpleAroundFilterObservation.lambda$wrap$0(ObservationFilterChainDecorator.java:323) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:224) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:233) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:191) ~[spring-security-web-6.1.4.jar:6.1.4]**
** at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:352) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:268) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.12.jar:6.0.12]**
** at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.13.jar:10.1.13]**
** at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]**
Caused by: com.thoughtworks.xstream.converters.ConversionException: No converter available
---- Debugging information ----
message : No converter available
type : java.util.ImmutableCollections$List12
converter : com.thoughtworks.xstream.converters.reflection.SerializableConverter
message[1] : Unable to make private void java.util.ImmutableCollections$List12.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not “opens java.util” to unnamed module @4fb3ee4e
converter[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[2] : Unable to make field private final java.lang.Object java.util.ImmutableCollections$List12.e0 accessible: module java.base does not “opens java.util” to unnamed module @4fb3ee4e
-------------------------------
** at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:88) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:478) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:49) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:87) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeBareItem(AbstractCollectionConverter.java:94) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeCompleteItem(AbstractCollectionConverter.java:81) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:75) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:87) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeBareItem(AbstractCollectionConverter.java:94) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeCompleteItem(AbstractCollectionConverter.java:81) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:75) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174) ~[xstream-1.4.19.jar:1.4.19]**
** at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshorg.axonframework.extensions.mongo.eventsourcing.eventstore.documentperevent.EventEntry.(EventEntry.java:67) ~[axon-mongo-4.8.0.jar:4.8.0]**
** at org.axonframework.extensions.mongo.eventsourcing.eventstore.documentperevent.DocumentPerEventStorageStrategy.lambda$createEventDocuments$0(DocumentPerEventStorageStrategy.java:58) ~[axon-mongo-4.8.0.jar:4.8.0]**
** at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]**
** at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]**
** at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]**
** at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]**
** at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]**
** at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[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:682) ~[na:na]**
** at org.axonframework.extensions.mongo.eventsourcing.eventstore.AbstractMongoEventStorageStrategy.appendEvents(AbstractMongoEventStorageStrategy.java:95) ~[axon-mongo-4.8.0.jar:4.8.0]**
** at org.axonframework.extensions.mongo.eventsourcing.eventstore.MongoEventStorageEngine.lambda$appendEvents$2(MongoEventStorageEngine.java:122) ~[axon-mongo-4.8.0.jar:4.8.0]**
** at org.axonframework.common.transaction.TransactionManager.executeInTransaction(TransactionManager.java:47) ~[axon-messaging-4.8.0.jar:4.8.0]**
** at org.axonframework.extensions.mongo.eventsourcing.eventstore.MongoEventStorageEngine.appendEvents(MongoEventStorageEngine.java:121) ~[axon-mongo-4.8.0.jar:4.8.0]**
** … 133 common frames omitted****strong text**

Those are two different kinds of errors.

For the first one it seems you are trying to create the ‘same’ aggregate twice. Each aggregate should have an unique ID. I’m not sure what the origin of the error is.

For the second one, it’s the famous using XStream as serializer + recent Java version. As XStream is the default. The easiest way around this, is to use Jackson instead. For example by adding axon.serializer.general=jackson to the properties.

Hello Gerard,

Thanks for the quick reply.

Now we have changed the eventstorage bean configuration where we have replaced the Xstream serializer with the Jackson serializer but we are getting some new errors. Please find below the event storage bean configuration code. Please review it if it is ok or not.

@Bean(“eventStorageEngine”)
public EventStorageEngine storageEngine(MongoDatabaseFactory factory,
TransactionManager transactionManager) {
return MongoEventStorageEngine.builder()
.mongoTemplate(SpringMongoTemplate.builder()
.factory(mongoDatabaseFactory())
.build())
.transactionManager(transactionManager)
.eventSerializer(JacksonSerializer.defaultSerializer())
.snapshotSerializer(JacksonSerializer.defaultSerializer())
.build();
}

org.axonframework.serialization.SerializationException: Error while deserializing payload of message d508f7fb-2164-4087-9b40-45b6420efd
49
at org.axonframework.serialization.SerializedMessage.getPayload(SerializedMessage.java:81) ~[axon-messaging-4.8.0.jar:4.8.0]
at org.axonframework.messaging.MessageDecorator.getPayload(MessageDecorator.java:56) ~[axon-messaging-4.8.0.jar:4.8.0]
at org.axonframework.messaging.annotation.PayloadParameterResolver.resolveParameterValue(PayloadParameterResolver.java:41) ~[ax
on-messaging-4.8.0.jar:4.8.0]
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.resolveParameterValues(AnnotatedMessageHandlingMember.
java:177) ~[axon-messaging-4.8.0.jar:4.8.0]
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(AnnotatedMessageHandlingMember.java:153) ~[axon
-messaging-4.8.0.jar:4.8.0]
at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64) ~[axon-mess
aging-4.8.0.jar:4.8.0]
at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.lambda$handle$1(TracingHandlerEnhancerDefinition.java:84) ~[axo
n-messaging-4.8.0.jar:4.8.0]
at org.axonframework.tracing.Span.runCallable(Span.java:132) ~[axon-messaging-4.8.0.jar:4.8.0]
at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.handle(TracingHandlerEnhancerDefinition.java:84) ~[axon-messagi
ng-4.8.0.jar:4.8.0]
at org.axonframework.messaging.annotation.NoMoreInterceptors.handle(NoMoreInterceptors.java:46) ~[axon-messaging-4.8.0.jar:4.8.
0]

Could it be there are still xml messages from XStream that can’t be serialized using Jackson? It seems like the root cause is not part of the shared stack trace.