微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决升级到 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'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。