Problem uprading SpringBoot-Application from Version 4.6.7 to 4.10.2

Hey,

I would like to update my Maven application and use axon version 4.10.2 (previously 4.6.7). I use the following dependencies:

<dependency>
				<groupId>org.axonframework</groupId>
				<artifactId>axon-spring</artifactId>
				<version>4.10.2</version>
			</dependency>
			<dependency>
				<groupId>org.axonframework</groupId>
				<artifactId>axon-spring-boot-starter</artifactId>
				<version>4.10.2</version>
			</dependency>
			<dependency>
				<groupId>org.axonframework</groupId>
				<artifactId>axon-messaging</artifactId>
				<version>4.10.2</version>
			</dependency>
			<dependency>
				<groupId>org.axonframework</groupId>
				<artifactId>axon-modelling</artifactId>
				<version>4.10.2</version>
			</dependency>
			<dependency>
				<groupId>org.axonframework.extensions.mongo</groupId>
				<artifactId>axon-mongo</artifactId>
				<version>4.10.0</version>
				<exclusions>
					<exclusion>
						<artifactId>axon-eventsourcing</artifactId>
						<groupId>org.axonframework</groupId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>org.axonframework</groupId>
				<artifactId>axon-test</artifactId>
				<version>4.10.2</version>
				<scope>test</scope>
			</dependency>

So far I have been able to start the legacy application without any problems. Now I get the following stacktrace:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventListener' defined in file [C:\Users\kaile\git\augmented-manufacturing\production-lifecycle\am-octoprint\target\classes\de\ftk\am\octoprint\EventListener.class]: Unsatisfied dependency expressed through constructor parameter 4: Error creating bean with name 'eventGateway' defined in class path resource [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eventGateway' parameter 0: Error creating bean with name 'eventStore' defined in class path resource [org/axonframework/springboot/autoconfig/AxonServerBusAutoConfiguration.class]: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception with message: javax/mail/MessagingException
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1371) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1208) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:288) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1122) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1093) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1030) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.0.jar:6.2.0]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.0.jar:6.2.0]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.4.0.jar:3.4.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.4.0.jar:3.4.0]
	at de.ftk.am.AmUiApplication.main(AmUiApplication.java:25) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventGateway' defined in class path resource [org/axonframework/springboot/autoconfig/AxonAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eventGateway' parameter 0: Error creating bean with name 'eventStore' defined in class path resource [org/axonframework/springboot/autoconfig/AxonServerBusAutoConfiguration.class]: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception with message: javax/mail/MessagingException
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:546) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1351) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:288) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1626) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1514) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-6.2.0.jar:6.2.0]
	... 21 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventStore' defined in class path resource [org/axonframework/springboot/autoconfig/AxonServerBusAutoConfiguration.class]: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception with message: javax/mail/MessagingException
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1351) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:563) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:288) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1626) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1514) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-6.2.0.jar:6.2.0]
	... 35 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception with message: javax/mail/MessagingException
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:199) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:88) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:168) ~[spring-beans-6.2.0.jar:6.2.0]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-6.2.0.jar:6.2.0]
	... 49 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/mail/MessagingException
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578) ~[na:na]
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2676) ~[na:na]
	at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.initializeMessageHandlers(AnnotatedHandlerInspector.java:205) ~[axon-messaging-4.10.2.jar:4.10.2]
	at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.initialize(AnnotatedHandlerInspector.java:197) ~[axon-messaging-4.10.2.jar:4.10.2]
	at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.createInspector(AnnotatedHandlerInspector.java:153) ~[axon-messaging-4.10.2.jar:4.10.2]
	at org.axonframework.messaging.annotation.AnnotatedHandlerInspector.inspectType(AnnotatedHandlerInspector.java:138) ~[axon-messaging-4.10.2.jar:4.10.2]
	at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory.createModel(AnnotatedAggregateMetaModelFactory.java:194) ~[axon-modelling-4.10.2.jar:4.10.2]
	at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory.createModel(AnnotatedAggregateMetaModelFactory.java:73) ~[axon-modelling-4.10.2.jar:4.10.2]
	at org.axonframework.config.AggregateConfigurer.lambda$new$7(AggregateConfigurer.java:188) ~[axon-configuration-4.10.2.jar:4.10.2]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.10.2.jar:4.10.2]
	at org.axonframework.config.AggregateConfigurer.lambda$new$17(AggregateConfigurer.java:204) ~[axon-configuration-4.10.2.jar:4.10.2]
	at org.axonframework.config.Component.get(Component.java:85) ~[axon-configuration-4.10.2.jar:4.10.2]
	at org.axonframework.config.AggregateConfigurer.snapshotFilter(AggregateConfigurer.java:486) ~[axon-configuration-4.10.2.jar:4.10.2]
	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:1708) ~[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.reduce(ReferencePipeline.java:657) ~[na:na]
	at org.axonframework.config.Configuration.snapshotFilter(Configuration.java:424) ~[axon-configuration-4.10.2.jar:4.10.2]
	at org.axonframework.springboot.autoconfig.AxonServerBusAutoConfiguration.eventStore(AxonServerBusAutoConfiguration.java:151) ~[axon-spring-boot-autoconfigure-4.10.2.jar:4.10.2]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.2.0.jar:6.2.0]
	... 52 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
	... 78 common frames omitted

Does anyone have an idea what the error could be?

Did you run the open rewrite script and/or did the changes pointed out here?

Thanks for mentioning it, I wasn’t aware of the site. I’ll take a look.

Did the referred-to post resolve the issue for you, @Kai_lfkr?

For others reading this post, let me give a little more context.
The 4.7 release of Axon Framework introduced support for Spring Boot 3. However, we did not want to remove Spring Boot 2 support in Axon Framework in a minor release (since that’s a massive breaking change).

Hence, we adjusted Axon Framework to support both Spring Boot 2 and Spring Boot 3. This includes a switch from javax to jakarta for a multitude of components within AF, because SB upgraded to JDK17 in that flow.

As SB3 is the feature, AF adjusted the infrastructure components to use the jakarta versions by default. Thus, if you are not both adjusting the Axon Framework, Spring Boot, and javax/jakarta specific dependencies in one go, you need to consciously choose the angle you require.

The referred-to post by Gerard contains an Open Rewrite script that automates that for you. The script itself is part of Axon Framework.