Trying to use axon-framework with spring boot 2.1.4. When I add spring-boot-devtools dependency I get the following exception:
java.lang.LinkageError: loader constraint violation in interface itable initialization for class org.axonframework.spring.config.AxonConfiguration: when selecting method org.axonframework.config.Configuration.resourceInjector()Lorg/axonframework/modelling/saga/ResourceInjector; the class loader 'app' (instance of jdk.internal.loader.ClassLoaders$AppClassLoader) for super interface org.axonframework.config.Configuration, and the class loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @3acec512 (instance of org.springframework.boot.devtools.restart.classloader.RestartClassLoader, child of 'app' jdk.internal.loader.ClassLoaders$AppClassLoader) of the selected method's type, org.axonframework.spring.config.AxonConfiguration have different Class objects for the type org.axonframework.modelling.saga.ResourceInjector used in the signature
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
at org.axonframework.common.ReflectionUtils.methodsOf(ReflectionUtils.java:229) ~[axon-messaging-4.1.1.jar:4.1.1]
at org.axonframework.spring.config.SpringAxonAutoConfigurer.lambda$registerEventHandlerRegistrar$42(SpringAxonAutoConfigurer.java:254) ~[axon-spring-4.1.1.jar:4.1.1]
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
at org.axonframework.spring.config.SpringAxonAutoConfigurer.registerEventHandlerRegistrar(SpringAxonAutoConfigurer.java:248) ~[axon-spring-4.1.1.jar:4.1.1]
at org.axonframework.spring.config.SpringAxonAutoConfigurer.registerBeanDefinitions(SpringAxonAutoConfigurer.java:214) ~[axon-spring-4.1.1.jar:4.1.1]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:364) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:na]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:363) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:145) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at pm.mbo.easyway.api.app.AppApi.main(AppApi.java:10) ~[main/: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.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.1.4.RELEASE.jar:2.1.4.RELEASE]
Found #491 but couldn't find a way to get around the exception. The only thing that works is removing devtools..
Thanks for filing this issue @mbogner. At the moment we suggest not to use the devtools, which as you've noticed does solve the issue. As @abuijze points out in the issue you've shared, it has to do with differing class loaders. It's under investigation from our part.
As soon as this is resolved, we'll insure this issue will be updated.
With Spring Boot (I'm currently at 2.1.3) I think I resolved devtools issues by creating a file:
/src/main/resources/META-INF/spring-devtools.properties
restart.include.modelmapper=/modelmapper-(.*).jar
restart.include.axon=/axon-(.*).jar
My project was also adding/getting started with a library called modelmapper which had similar warnings for using Spring Boot Devtools.
http://modelmapper.org/user-manual/spring-boot-devtools-integration/
I thought why not try the same workaround for Axon? And so far so good for a number of months now and a few Spring Boot version bumps. I don't know where this workaround may fall flat for others...
Thanks for that suggestion @thydian!
@mbogner, would you mind trying out whether the shared solution resolves the issue for you as well?
@thydian @smcvb
Thanks, putting the file with given content in place also solved the issue for me. Now it works with devtools included.
PS: Didn't close the issue as this seems to be a workaround for an existing bug for me.
I have the same issue, and I have solved with @thydian workaround.
@mbogner it's indeed fine/correct to maintain this issue further. Ideally, the framework would provide a solution for this i.o. the user being required to set up such a file.
@mborra thanks for sharing that following the provided suggestion solved the issue for you as well.
Closing this issue as "obsolete" in favor of issue #1382.
Most helpful comment
With Spring Boot (I'm currently at 2.1.3) I think I resolved devtools issues by creating a file:
/src/main/resources/META-INF/spring-devtools.properties
restart.include.modelmapper=/modelmapper-(.*).jarrestart.include.axon=/axon-(.*).jarMy project was also adding/getting started with a library called modelmapper which had similar warnings for using Spring Boot Devtools.
http://modelmapper.org/user-manual/spring-boot-devtools-integration/
I thought why not try the same workaround for Axon? And so far so good for a number of months now and a few Spring Boot version bumps. I don't know where this workaround may fall flat for others...