I am maintaining a Java SDK that, due to historical reasons, has integrated many third-party dependencies, including common ones such as Spring and gRPC.
The current Spring Boot version on the client is 2.5.14, and I plan to integrate the SDK into the client. The client's Spring Boot version can run normally on versions 2.2.0.RELEASE to 2.7.14, but cannot start on versions 2.1.18.RELEASE and below (2.0.0.RELEASE to 2.1.18.RELEASE). The corresponding incompatible Spring versions are those below 5.2.
The error message is as follows:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gtxsTransactionAspectSupport': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.netease.cloud.gtxs.core.rm.transaction.GtxsTransactionAspectSupport] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:262) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1198) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:513) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:484) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:618) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:177) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 17 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.netease.cloud.gtxs.core.rm.transaction.GtxsTransactionAspectSupport] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:245) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 31 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/transaction/TransactionManager
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_312]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2729) ~[na:1.8.0_312]
at java.lang.Class.getDeclaredMethods(Class.java:2003) ~[na:1.8.0_312]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 34 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.TransactionManager
at java.net.URLClassLoader.findClass(URLClassLoader.java:387) ~[na:1.8.0_312]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_312]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[na:1.8.0_312]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_312]
... 38 common frames omitted
I found that the SDK uses Spring's transactional functionality and inherits the TransactionAspectSupport
class (org.springframework.transaction.interceptor.TransactionAspectSupport
). TransactionAspectSupport
contains a member object transactionManager
, which is an abstract interface added in Spring 5.2. Previous versions did not have this member and instead had a member of type PlatformTransactionManager
. This is consistent with the client integration error message, leading me to suspect that this might be the cause of the compatibility issue. However, the SDK code does not directly reference TransactionManager
, and even when I configure the spring-tx
dependency as 'provided', the error still occurs. This is very confusing to me. What could be the root cause of this issue?
I attempted to resolve this issue by setting the spring-tx dependency of the SDK to 'provided', with the aim of using the client's Spring-tx. However, the error remains the same.