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

Spring JIRA | Jayaram Pradhan | 6 months ago
  1. 0

    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)

    Spring JIRA | 6 months ago | 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
  2. 0

    Redis (AWS Elasticache) stops working after sometime

    Stack Overflow | 3 weeks ago | Gaurav Srivastava
    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
  3. 0

    Is possible connect on CODIS using Jedi?

    GitHub | 11 months ago | thiagohora
    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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring HTTP actuator fails if Redis (via Spring Session) is down

    GitHub | 12 months ago | davidmelia
    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
  6. 0

    spring-boot连接redis错误 - SegmentFault

    segmentfault.com | 4 months ago
    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

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. Spring Data Redis
      JedisConnectionFactory.fetchJedisConnector
      1. org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:198)
      1 frame