升级到 spring-geode-starter 1.4.2 会产生条件、自省和 ClassNotFoundExceptions

问题描述

一段时间后返回 Geode 反应流项目时,我想升级到最新的 spring-geode-starter。也许与 Spring Boot Geode Unsatisfied dependency expressed through method 'sessionRegion' 也有关 ClientCacheConfiguration 我认为是一个简单的 build.gradle 依赖项给出了例外:

2021-02-03T07:36:55,171 ERROR [main] org.springframework.boot.SpringApplication 856 reportFailure: Application run failed
java.lang.IllegalStateException: Error processing condition on org.springframework.geode.boot.autoconfigure.CachingProviderAutoConfiguration
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:489)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:478)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:478)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:348)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:252)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:285)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:99)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:751)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:569)
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:63)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
    at app.FixApi.main(FixApi.java:23)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2f333739]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358)
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:754)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:753)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:692)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:663)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1670)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:238)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:231)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:221)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:169)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:119)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    ... 20 more
Caused by: java.lang.NoClassDefFoundError: org/apache/geode/cache/client/SocketFactory
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
    ... 36 more
Caused by: java.lang.ClassNotFoundException: org.apache.geode.cache.client.SocketFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 40 more

我的 build.gradle 依赖项是:

dependencies {
group = 'api'
description = 'streaming api'

// This dependency is exported to consumers,that is to say found on their compile classpath.
// api 'org.apache.commons:commons-math3:3.6.1'

// Geode client dependency
implementation 'org.springframework.geode:spring-geode-starter:1.4.2'    
implementation 'org.springframework.boot:spring-boot-starter-tomcat' 

implementation 'org.springframework.boot:spring-boot-starter-log4j2:2.4.2'
implementation 'com.lmax:disruptor:3.4.2'

implementation 'org.springframework.boot:spring-boot-starter-webflux:2.4.2'
implementation 'org.springframework.boot:spring-boot-starter-rsocket:2.4.2'

// tag::actuator[]
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.4.2'
// end::actuator[]

// HTML manager
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.4.2'

implementation 'com.google.guava:guava:30.1-jre'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.json:json:20201115'

implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'org.projectlombok:lombok:1.18.16'
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'

// Geode tests
testImplementation 'org.springframework.data:spring-data-geode-test:0.0.22'

// Other test dependencies
testImplementation 'io.projectreactor:reactor-test:3.4.2'
testImplementation 'org.springframework.security:spring-security-test' 
testImplementation 'org.springframework.data:spring-data-geode-test:0.0.22'

testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage',module: 'junit-vintage-engine'
}
  
testCompile group: 'org.springframework.boot',name: 'spring-boot-starter-test',version: '2.4.2'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}

解决方法

我不确定如何(在上面显示的 Gradle 构建中查看您的依赖项),但是 Apache Geode API 类 {{1} 上的 NoClassDefFoundError/ClassNotFoundException }} 是由不兼容的 Apache Geode 版本(即 org.apache.geode.cache.client.SocketFactory 之前的版本)引起的。

SocketFactory 类实际上是在 Apache Geode 1.13 中引入的(请参阅 here,然后尝试 here)。

确实是 SBDG 1.13 pulls in SDG 1.4.2,也就是 based on Apache Geode 2.4.3。从 SBDG Version Compatibility Matrix 中也可以看出这一点。

您可以尝试运行:

1.13.1

并搜索所有 $ gradlew dependencies | less 依赖项(只需搜索“geode-core”)并查看正在使用、覆盖的 Apache Geode 版本等。

但是,每当您看到 org.apache.geode:geode-core/NoClassDefFoundErrorClassNotFoundException 这类性质的错误时,您可以打赌,十分之九是您遇到了版本问题。

,

这是通过检查 Version-Compatibility-and-Support-Matrix 并选择

解决的

implementation 'org.springframework.geode:spring-geode-starter:1.2.8.RELEASE'

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...