Spring cache with Redis: NullPointerException -


when added @cacheable annotation service method , executed it, got following error:

java.lang.exceptionininitializererror     @ org.springframework.data.redis.connection.jedis.jedisconnectionfactory.getconnection(jedisconnectionfactory.java:252)     @ org.springframework.data.redis.connection.jedis.jedisconnectionfactory.getconnection(jedisconnectionfactory.java:58)     @ org.springframework.data.redis.core.redisconnectionutils.dogetconnection(redisconnectionutils.java:128)     @ org.springframework.data.redis.core.redisconnectionutils.getconnection(redisconnectionutils.java:91)     @ org.springframework.data.redis.core.redisconnectionutils.getconnection(redisconnectionutils.java:78)     @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:178)     @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:153)     @ org.springframework.data.redis.cache.rediscache.get(rediscache.java:104)     @ org.springframework.data.redis.cache.rediscache.get(rediscache.java:90)     @ org.springframework.cache.interceptor.abstractcacheinvoker.doget(abstractcacheinvoker.java:68)     @ org.springframework.cache.interceptor.cacheaspectsupport.findincaches(cacheaspectsupport.java:461)     @ org.springframework.cache.interceptor.cacheaspectsupport.findcacheditem(cacheaspectsupport.java:432)     @ org.springframework.cache.interceptor.cacheaspectsupport.execute(cacheaspectsupport.java:333)     @ org.springframework.cache.interceptor.cacheaspectsupport.execute(cacheaspectsupport.java:299)     @ org.springframework.cache.interceptor.cacheinterceptor.invoke(cacheinterceptor.java:61)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207)     @ com.sun.proxy.$proxy33.findmember(unknown source)     @ com.fh.taolijie.test.dao.mapper.accountservicetest.testfind(accountservicetest.java:38)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:50)     @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12)     @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:47)     @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17)     @ org.springframework.test.context.junit4.statements.runbeforetestmethodcallbacks.evaluate(runbeforetestmethodcallbacks.java:73)     @ org.springframework.test.context.junit4.statements.runaftertestmethodcallbacks.evaluate(runaftertestmethodcallbacks.java:82)     @ org.springframework.test.context.junit4.statements.springrepeat.evaluate(springrepeat.java:73)     @ org.junit.runners.parentrunner.runleaf(parentrunner.java:325)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:224)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:83)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:290)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:58)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268)     @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61)     @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:68)     @ org.junit.runners.parentrunner.run(parentrunner.java:363)     @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:163)     @ org.junit.runner.junitcore.run(junitcore.java:137)     @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:78)     @ com.intellij.rt.execution.junit.junitstarter.preparestreamsandstart(junitstarter.java:212)     @ com.intellij.rt.execution.junit.junitstarter.main(junitstarter.java:68)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) caused by: java.lang.nullpointerexception     @ org.springframework.util.reflectionutils.makeaccessible(reflectionutils.java:443)     @ org.springframework.data.redis.connection.jedis.jedisconnection.<clinit>(jedisconnection.java:108)     ... 51 more 

my configuration bean:

@bean     public jedisconnectionfactory jedisconnectionfactory() {         jedisconnectionfactory connectionfactory = new jedisconnectionfactory();         connectionfactory.afterpropertiesset();          return connectionfactory;     }      @bean     public redistemplate<string, membermodel> redistemplate() {         redistemplate<string, membermodel> template = new redistemplate<>();         template.setconnectionfactory(this.jedisconnectionfactory);         template.afterpropertiesset();          return template;     }      @bean     public cachemanager cachemanager() {         rediscachemanager rediscachemanager = new rediscachemanager(redistemplate);         rediscachemanager.afterpropertiesset();          return rediscachemanager;     } 

method needs cache:

  @override     @transactional(readonly = true)     @cacheable(value = "membercache", key = "#username")     public membermodel findmember(string username, boolean iswired) {         membermodel mem = memmapper.selectbyusername(username);         checkutils.nullcheck(mem);          return mem;     } 

everything looks normal. can't tell what's wrong here..

this due version compatibility between jedis , spring-data.

saw - spring data redis 1.5.0 seems compatible jedis 2.6.2

cannot connection redistemplate spring data redis


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -