Search code examples
netflix-eurekaspring-data-redis

Caused by: java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.getConfig(Ljava/lang/String;)Ljava/util/List;


I get this error when I'm trying to run my eureka server using properties from config server and I add this:

  • spring.redis.host=localhost

  • spring.redis.port=6379

    I have also redis server running in my machine

My config server is running correctly.

It looks like it didn't get the configuration properties

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v2.0.4.RELEASE)[0;39m

[2m2018-08-23 19:44:29.966[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.c.c.ConfigServicePropertySourceLocator[0;39m [2m:[0;39m Fetching config from server at : http://localhost:8081
[2m2018-08-23 19:44:31.137[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.c.c.ConfigServicePropertySourceLocator[0;39m [2m:[0;39m Located environment: name=discovery, profiles=[default], label=null, version=052b600a442973c1255a385b023aa3b78f1cb98e, state=null
[2m2018-08-23 19:44:31.138[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mb.c.PropertySourceBootstrapConfiguration[0;39m [2m:[0;39m Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='file://C:/Users/PC/pfe-config/discovery.properties'}]}
[2m2018-08-23 19:44:31.149[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36ms.pfe.meter.DiscoveryServerApplication  [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2018-08-23 19:44:31.240[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5026735c: startup date [Thu Aug 23 19:44:31 GMT+01:00 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@765d7657
[2m2018-08-23 19:44:33.525[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Multiple Spring Data modules found, entering strict repository configuration mode!
[2m2018-08-23 19:44:34.640[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.cloud.context.scope.GenericScope    [0;39m [2m:[0;39m BeanFactory id=7ea2c4ae-a908-3ab0-99f1-53f853a13e36
[2m2018-08-23 19:44:34.699[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mf.a.AutowiredAnnotationBeanPostProcessor[0;39m [2m:[0;39m JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
[2m2018-08-23 19:44:35.007[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$efb3243] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2018-08-23 19:44:35.728[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8082 (http)
[2m2018-08-23 19:44:36.019[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2018-08-23 19:44:36.020[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet Engine: Apache Tomcat/8.5.32
[2m2018-08-23 19:44:36.028[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.a.catalina.core.AprLifecycleListener  [0;39m [2m:[0;39m The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_111\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_111/bin/server;C:/Program Files/Java/jre1.8.0_111/bin;C:/Program Files/Java/jre1.8.0_111/lib/amd64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\MongoDB\Server\3.0\bin;C:\Program Files\nodejs\;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\cygwin64\bin;C:\Users\PC\AppData\Local\Microsoft\WindowsApps;C:\Users\PC\AppData\Roaming\npm;C:\Program Files\apache-maven-3.5.4\bin;;D:\spring-tool-suite-3.9.5.RELEASE-e4.8.0-win32-x86_64\sts-bundle\sts-3.9.5.RELEASE;;.]
[2m2018-08-23 19:44:36.383[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2018-08-23 19:44:36.384[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.web.context.ContextLoader           [0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 5144 ms
[2m2018-08-23 19:44:36.800[0;39m [33m WARN[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2018-08-23 19:44:36.800[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2018-08-23 19:44:36.822[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.netflix.config.DynamicPropertyFactory [0;39m [2m:[0;39m DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@3e1ff2c0
[2m2018-08-23 19:44:41.018[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'characterEncodingFilter' to: [/*]
[2m2018-08-23 19:44:41.019[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'webMvcMetricsFilter' to: [/*]
[2m2018-08-23 19:44:41.019[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'sessionRepositoryFilter' to: [/*]
[2m2018-08-23 19:44:41.019[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
[2m2018-08-23 19:44:41.020[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'httpPutFormContentFilter' to: [/*]
[2m2018-08-23 19:44:41.020[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'requestContextFilter' to: [/*]
[2m2018-08-23 19:44:41.021[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36m.s.DelegatingFilterProxyRegistrationBean[0;39m [2m:[0;39m Mapping filter: 'springSecurityFilterChain' to: [/*]
[2m2018-08-23 19:44:41.022[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'httpTraceFilter' to: [/*]
[2m2018-08-23 19:44:41.022[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean  [0;39m [2m:[0;39m Mapping filter: 'servletContainer' to urls: [/eureka/*]
[2m2018-08-23 19:44:41.022[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mo.s.b.w.servlet.ServletRegistrationBean [0;39m [2m:[0;39m Servlet dispatcherServlet mapped to [/]
[2m2018-08-23 19:44:41.168[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.s.j.s.i.a.WebApplicationImpl          [0;39m [2m:[0;39m Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
[2m2018-08-23 19:44:41.414[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider  [0;39m [2m:[0;39m Using JSON encoding codec LegacyJacksonJson
[2m2018-08-23 19:44:41.417[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider  [0;39m [2m:[0;39m Using JSON decoding codec LegacyJacksonJson
[2m2018-08-23 19:44:41.684[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider  [0;39m [2m:[0;39m Using XML encoding codec XStreamXml
[2m2018-08-23 19:44:41.685[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[ost-startStop-1][0;39m [36mc.n.d.provider.DiscoveryJerseyProvider  [0;39m [2m:[0;39m Using XML decoding codec XStreamXml
[2m2018-08-23 19:44:43.029[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.s.web.DefaultSecurityFilterChain    [0;39m [2m:[0;39m Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/eureka/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@47768e74, org.springframework.security.web.context.SecurityContextPersistenceFilter@e38f0b7, org.springframework.security.web.header.HeaderWriterFilter@dd2856e, org.springframework.security.web.authentication.logout.LogoutFilter@f5ce0bb, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2525a5b8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4f8d86e4, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6e3eb0cd, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@2740e316, org.springframework.security.web.session.SessionManagementFilter@777d191f, org.springframework.security.web.access.ExceptionTranslationFilter@b0a1231, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@58606c91]
[2m2018-08-23 19:44:43.034[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.s.web.DefaultSecurityFilterChain    [0;39m [2m:[0;39m Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@79aee22a, org.springframework.security.web.context.SecurityContextPersistenceFilter@1cfc2538, org.springframework.security.web.header.HeaderWriterFilter@3451f01d, org.springframework.security.web.authentication.logout.LogoutFilter@2ecf5915, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@66deec87, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5d342959, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@36920bd6, org.springframework.security.web.session.SessionManagementFilter@72503b19, org.springframework.security.web.access.ExceptionTranslationFilter@124d02b2, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6bcc3f27]
[2m2018-08-23 19:44:43.301[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mio.lettuce.core.EpollProvider           [0;39m [2m:[0;39m Starting without optional epoll library
[2m2018-08-23 19:44:43.304[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mio.lettuce.core.KqueueProvider          [0;39m [2m:[0;39m Starting without optional kqueue library
[2m2018-08-23 19:44:44.183[0;39m [33m WARN[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.getConfig(Ljava/lang/String;)Ljava/util/List;
[2m2018-08-23 19:44:45.318[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Stopping service [Tomcat]
[2m2018-08-23 19:44:45.369[0;39m [32m INFO[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2018-08-23 19:44:45.394[0;39m [31mERROR[0;39m [35m9156[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.getConfig(Ljava/lang/String;)Ljava/util/List;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at steg.pfe.meter.DiscoveryServerApplication.main(DiscoveryServerApplication.java:16) [classes/:na]
Caused by: java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.getConfig(Ljava/lang/String;)Ljava/util/List;
    at org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction.getNotifyOptions(ConfigureNotifyKeyspaceEventsAction.java:74) ~[spring-session-1.3.3.RELEASE.jar:na]
    at org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction.configure(ConfigureNotifyKeyspaceEventsAction.java:55) ~[spring-session-1.3.3.RELEASE.jar:na]
    at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterPropertiesSet(RedisHttpSessionConfiguration.java:251) ~[spring-session-1.3.3.RELEASE.jar:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    ... 16 common frames omitted

Solution

  • This question is everywhere but with no definitive answer.

    Its been 9months and you probably solved it by now, but I'll still provide this answer for those it may help.

    Even though I would actually recommend you post your maven or gradle build file as well as your connectionFactory code for more clarity of context, I'll take a wild guess and attempt to provide a possible solution with a brief explanation below;

    Many times this kind of problem could be caused either by;

    1. Library/Version incompatibilities of your project dependencies OR
    2. Having more than one library(ies) on your classpath that have the same class(es), hence causing a collission.

    In either case, Spring will have a hard time figuring out what library and what version of the dependencies to use in your project.

    I experienced something similar to what you're experiencing and the solution for me was to purge my dependencies so I decided keep only spring-session-data-redis and removed all other spring-session and/or data-redis dependencies

    <dependency>
        <groupId>org.springframework.session</groupId>
        <artifactId>spring-session-data-redis</artifactId>
    </dependency>
    

    If this does not work for you, then you really should post some code to further help understand your situation