AxonFramework: Axon doesn't work in combination with spring-boot-dev-tools on class path
Axon version: 3.0.2 With: spring-boot-axon + H2 + No cache repository
If you add spring-boot-dev-tools
in your class path, axon will not work. I am not sure, but spring-boot-dev-tools
will change the path class name of event message object and during the publishing this event will not match.
I make an example here -> https://github.com/moifort/axon-sample-with-spring-dev-tools
Make the test by removing/adding spring-boot-dev-tools
dependency
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (9 by maintainers)
Commits related to this issue
- Configured Axon jars to use reload classloader in Spring Boot DevTools Also set the bean class loader to be used as the classloader in the default XStream serializer. This would also be the reload cl... — committed to AxonFramework/AxonFramework by abuijze 7 years ago
- Remove the spring-boot-devtools dependency from pom.xml Axon doesn't work in combination with spring-boot-devtools on classpath. See https://github.com/AxonFramework/AxonFramework/issues/282 — committed to djschilling/escqrs-demo by omessner 7 years ago
- 去掉spring boot dev tool,规避 classloader的混乱。 https://github.com/AxonFramework/AxonFramework/issues/282 — committed to JoeCao/OrderEventDrivenDemo by JoeCao 7 years ago
Did some test with the sample project given by @moifort The Axon jars are just one part, the serializer has to be included too. What finally worked:
Depending on the serializer chosen by the developer you have to include more dependencies (with unknown side effects). I think this should not be handled by Axon. Just add a section to the README and give some examples for common use cases.
We’ve prioritized a fix/solution for the
spring-dev-tools
issue in #1382 for release 4.4. That issue links to the majority of the created issues aroundspring-dev-tools
, although I forget to reference this one; sorry for that unclarity.By the way, the file you’re referencing was intended as a fix for the users, although it indeed doesn’t work as expected.
I removed spring-boot-devtools from my pom.xml this is also working for me in production. Thanks a lot 😃
Seems like this can be resolved without touching XStream. There are multiple locations involved:
The JpaEventStorageEngine in JpaConfiguration is constructed without the Serializer Bean:
https://github.com/AxonFramework/AxonFramework/blob/master/spring-boot-autoconfigure/src/main/java/org/axonframework/boot/AxonAutoConfiguration.java#L173
The XStream instance of the XStreamSerializer is configured without a classLoader. So the ClassLoader of the library is used.
A working example is:
Add to
spring-devtools.properties
:Add a configuration class:
This solves the issues at least for XStream without adding the lib to devtools. Seems like Jackson provides an explicity ClassLoader too.
Does anybody know how to unit test such class loader related stuff?