Event storage engines cannot be used without XStream
See original GitHub issueBasic information
- Axon Framework version: 4.6.0
- JDK version: 11
Steps to reproduce
Create a simple Spring Boot Application using the axon-spring-boot-starter with excluded XStream:
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<version>4.6.0</version>
<exclusions>
<exclusion>
<groupId>org.axonframework</groupId>
<artifactId>axon-server-connector</artifactId>
</exclusion>
<exclusion>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</exclusion>
</exclusions>
</dependency>
Make sure that all serializers are set to jackson:
axon.serializer.general=jackson
axon.serializer.events=jackson
axon.serializer.messages=jackson
Expected behaviour
The application starts.
Actual behaviour
The application crashes due to a missing class.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘eventStorageEngine’ defined in class path resource [org/axonframework/springboot/autoconfig/JpaEventStoreAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStorageEngine]: Factory method ‘eventStorageEngine’ threw exception; nested exception is java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.22.jar:5.3.22] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3] at com.example.demo.DemoApplication.main(DemoApplication.java:10) ~[classes/:na] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStorageEngine]: Factory method ‘eventStorageEngine’ threw exception; nested exception is java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22] … 18 common frames omitted Caused by: java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/HierarchicalStreamDriver at org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine.builder(JpaEventStorageEngine.java:133) ~[axon-eventsourcing-4.6.0.jar:4.6.0] at org.axonframework.springboot.autoconfig.JpaEventStoreAutoConfiguration.eventStorageEngine(JpaEventStoreAutoConfiguration.java:58) ~[axon-spring-boot-autoconfigure-4.6.0.jar:4.6.0] at org.axonframework.springboot.autoconfig.JpaEventStoreAutoConfiguration$$EnhancerBySpringCGLIB$$26dca9f1.CGLIB$eventStorageEngine$0(<generated>) ~[axon-spring-boot-autoconfigure-4.6.0.jar:4.6.0] at org.axonframework.springboot.autoconfig.JpaEventStoreAutoConfiguration$$EnhancerBySpringCGLIB$$26dca9f1$$FastClassBySpringCGLIB$$425bb5fc.invoke(<generated>) ~[axon-spring-boot-autoconfigure-4.6.0.jar:4.6.0] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.22.jar:5.3.22] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.22.jar:5.3.22] at org.axonframework.springboot.autoconfig.JpaEventStoreAutoConfiguration$$EnhancerBySpringCGLIB$$26dca9f1.eventStorageEngine(<generated>) ~[axon-spring-boot-autoconfigure-4.6.0.jar:4.6.0] 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.22.jar:5.3.22] … 19 common frames omitted Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.io.HierarchicalStreamDriver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na] … 31 common frames omitted
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
Hi @smcvb,
Sounds good to me. I assumed that much.
Meanwhile we will continue with moving our code to 4.6.X and report further issues in case they arise. Unfortunately we have done a lot of customization making the migration from 4.5.15 to 4.6.0 more cumbersome than we originally hoped.
Closing this issue since pull request [#2369] resolves it. Thanks a bunch for filing this with us as soon as you did, @nils-christian. The effort is very much appreciated 😃
Note that we’ll hold off a patch release for Axon Framework a bit more. In part because more bugs might surface and in part because we’re quite busy with AxonIQ’s conference coming up. Added, I think the workaround for this is doable: simply not excluding XStream. Although I’d say it’s not ideal, it’s not pressing enough to warrant an immediate release somewhere this week.
If you or others reading this feel other wise, pleas tell us! I’m basing myself on user assumptions here, so I’d like to know if those are wrong.