Reputation: 13
Initially, my application was running fine with spring-data-gemfire 1.9.7.RELEASE. However, after upgrading to spring-data-gemfire 2.0.1.RELEASE, my application fails to start and throws an Initialization Error as shown below:
C:\Dev\projects\JavaWebClient\web\target>java -jar web-0.0.1-SNAPSHOT.jar
. ____ _ __ _ _
/\ / ' __ _ ()_ __ __ _ \ \ \ \
( ( )_ | '_ | '| | ' / ` | \ \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |____| .|| ||| |__, | / / / /
=========|_|==============|___/=///_/
:: Spring Boot :: (v1.5.8.RELEASE)[info 2017/11/15 19:07:23.999 EAT tid=0x1] Starting JavaWebClientApplication v0.0.1-SNAPSHOT on MY-PC with PID 13804 (C:\Dev\projects\JavaWebClient\web\target\web-0.0.1-SNAPSHOT.jar started by edwards in C:\Dev\projects\JavaWebClient\web\target)
[info 2017/11/15 19:07:24.019 EAT tid=0x1] No active profile set, falling back to default profiles: default
[info 2017/11/15 19:07:24.812 EAT tid=0x1] Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: startup date [Wed Nov 15 19:07:24 EAT 2017]; root of context hierarchy
[error 2017/11/15 19:07:25.892 EAT tid=0x1] Application startup failed java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; at org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension.registerBeansForRoot(GemfireRepositoryConfigurationExtensi on.java:120) at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:116) at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport. java:83) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$0(ConfigurationClassBeanDefini tionReader.java:360) at java.util.LinkedHashMap.forEach(Unknown Source) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReade r.java:359) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefiniti onReader.java:144) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.ja va:273) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
[info 2017/11/15 19:07:25.897 EAT tid=0x1] Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: startup date [Wed Nov 15 19:07:24 EAT 2017]; root of context hierarchy
[warn 2017/11/15 19:07:25.901 EAT tid=0x1] Exception thrown from LifecycleProcessor on context close java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: startup date [Wed Nov 15 19:07:24 EAT 2017]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:433) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1004) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:963) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
[error 2017/11/15 19:07:25.905 EAT tid=0x1] Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory ' threw an exception java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: startup date [Wed Nov 15 19:07:24 EAT 2017]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:420) at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:95) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:240) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:576) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:552) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:953) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:521) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:227) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:960) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1035) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1011) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:963) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
C:\Dev\projects\JavaWebClient\web\target>
Upvotes: 1
Views: 418
Reputation: 7981
Not surprising since your Spring application is based on Spring Boot 1.5.8.RELEASE
and it isn't clear how you specifically upgraded the Spring Data GemFire dependency from 1.9.7.RELEASE
to 2.0.1.RELEASE
.
The problem is, you are pulling in an incompatible version of Spring Data Commons as well as, and I suspect, several other Spring dependencies (e.g. the core Spring Framework) since your applications is rooted in Spring Boot 1.5.8.RELEASE
. Hence the java.lang.NoSuchMethodError
error...
java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional;
at org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension.registerBeansForRoot(GemfireRepositoryConfigurationExtensi on.java:120)
First, you need to understand that all Spring Data modules (see "Main modules", "Community modules" and "Related modules" and the section about the "Release train" on the SD project page) build on a particular version of both Spring Data Commons and the core Spring Framework. You cannot simply upgrade 1 dependency and not expect to have to upgrade others.
The SD Release Trains (such as Ingalls or Kay) are all based on a particular version of Spring Data Commons and the core Spring Framework. For instance, with SD Kay, see "Core themes" and "Participating modules".
The java.lang.NoSuchMethodError
is specifically occurring because you are using an incompatible version of Spring Data Commons (i.e. SDC 1.13.8.RELEASE
from Ingalls, which is pulled in by Spring Boot 1.5.x) with Spring Data GemFire 2.0.1.RELEASE
, which comes from SD Kay, and expects SDC 2.0.x.RELEASE
.
This class, (i.e. org.springframework.data.repository.config.RepositoryConfigurationSource
) is a Spring Data Commons class. Clearly the method signature (i.e. getAttribute(:String):String
) in SDC 1.13.8
(Ingalls) for the method in question is not what SDG 2.0.1.RELEASE
expects (i.e. getAttribute(:String):Optional<String>
), which comes from SDC 2.0.1.RELEASE
.
There is a reason why Spring Boot, and by extension, the Spring IO Platform, provide a curated and harmonized set of dependencies that have all been tested and proven to work together. When you deviate from the prescribed dependencies, you need to be mindful of this.
Technically, only the upcoming Spring Boot 2.0 release will be based on SD Kay.
However, if you do need a GA release of Spring Boot (i.e. 1.5.8.RELEASE
, the current latest) and wish to use Spring Data GemFire 2.0.1.RELEASE
, or Kay-SR1, then fortunately you are in luck!
I too wanted to use Spring Data Kay with the latest GA version of Spring Boot (i.e. 1.5.8.RELEASE) in the Spring IO Guides (for instance) to showcase the new features in Spring Data GemFire 2.0.x
Kay, since many things have changed for the better (like this).
I was able to get this to work, but I need to set specific things in the Maven (or Gradle) build file, such as overriding the dependency versions of SD and the core Spring Framework managed by Spring Boot (specifically this, and this). Note this as well. Also note my dependencies.
Gradle is a bit more tricky, but you can see the new build file here and compare it with the previous version here.
Anyway, keep these things in mind the next time you are wrangling dependency versions, which is the whole reason why Spring IO Platform was created in the first place, to manage all the dependencies and dependencies of dependencies (i.e. transitive dependencies) when possible overlap/conflicts occur (since certain transitive dependencies will have the same dependencies), etc, etc.
Hope this helps!
Regards, -j
Upvotes: 1