org.springframework.data.redis.RedisConnectionFailureException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • spring-boot连接redis错误 - SegmentFault
    via by Unknown author,
  • When Using *@EnableCaching(mode = AdviceMode.ASPECTJ)* for Redis Cache, custom error handler is not getting registered, however *AdviceMode.PROXY* is working as expected. Below is Cache Configuration {code:title=CacheConfiguration.java|borderStyle=solid} @Configuration @EnableCaching(mode = AdviceMode.ASPECTJ) public class AutoConfInitializer extends CachingConfigurerSupport { @Bean public RedisConnectionFactory jedisConnectionFactory(){ List<URI> uris = getURIS(); URI uri = uris.get(0); JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory(); redisConnectionFactory.setHostName(uri.getHost()); redisConnectionFactory.setPort(uri.getPort()); redisConnectionFactory.setPassword(uri.getUserInfo()); redisConnectionFactory.setUsePool(true); return redisConnectionFactory; } @Bean(name="redisTemplate") public RedisTemplate<Object, Object> redisTemplate() { RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); redisTemplate.setKeySerializer(new GenericJackson2JsonRedisSerializer()); return redisTemplate; } @Bean @Override public CacheManager cacheManager() { // configure and return an implementation of Spring's CacheManager SPI RedisCacheManager manager = new RedisCacheManager(redisTemplate()); // manager.setDefaultExpiration(); manager.setCacheNames(Collections.unmodifiableList(new ArrayList<>(getCacheProps().keySet()))); manager.setUsePrefix(Boolean.TRUE); manager.setExpires(getCacheProps()); manager.setCachePrefix(cacheName -> (getCachePrefix()+cacheName).getBytes()); return manager; } @Override @Bean public CacheErrorHandler errorHandler() { return new AutoConfInitializer.DefaultCacheErrorHandler(); } // @Configuration public static class DefaultCacheErrorHandler implements CacheErrorHandler { private static final Logger LOG = LoggerFactory.getLogger(DefaultCacheErrorHandler.class); @Override public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) { LOG.warn("[CACHE-CRITICAL]- Unable to retrieve from cache:{}", cache.getName(),exception); } @Override public void handleCachePutError(RuntimeException exception, Cache cache, Object key, Object value) { LOG.warn("[CACHE-CRITICAL]- Unable to Put in cache:{}", cache.getName(),exception); } @Override public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) { LOG.warn("[CACHE-CRITICAL]- Unable to Evict from cache:{}", cache.getName(),exception); } @Override public void handleCacheClearError(RuntimeException exception, Cache cache) { LOG.warn("[CACHE-CRITICAL]- Unable to clear cache:{}", cache.getName(),exception); } } {code} With advice mode aspectj getting the below exception (as the error handler is setting to SimpleCacheErrorHandler ): org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:198)
    via by Jayaram Pradhan,
    • org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:162) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:251) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:58) at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128) at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91) at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:178) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86) at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:169) at com.itapp.ItAppApiApplicationTests.test(ItAppApiApplicationTests.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

    Users with the same issue

    Kawada
    11 times, last one,