Could not get a resource from the pool

Posted --candice

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Could not get a resource from the pool相关的知识,希望对你有一定的参考价值。

异常描述: 

  1.  
    redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  2.  
    at redis.clients.util.Pool.getResource(Pool.java:22)
  3.  
    at com.derbysoft.jredis.longkeytest.BorrowObject.run(BorrowObject.java:22)
  4.  
    at java.lang.Thread.run(Thread.java:662)
  5.  
    Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
  6.  
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1134)
  7.  
    at redis.clients.util.Pool.getResource(Pool.java:20)
  8.  
    ... 2 more



1、产生原因:客户端去redis服务器拿连接(代码描述的是租用对象borrowObject)的时候,池中无可用连接,即池中所有连接被占用,且在等待时候设定的超时时间后还没拿到时,报出此异常。 

2、解决办法:调整JedisPoolConfig中maxActive为适合自己系统的阀值。 

<bean id="dataJedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> 
        <property name="maxActive" value="300"/> 
       <property name="maxIdle" value="100"/> 
        <property name="maxWait" value="10000"/> 
        <property name="testOnBorrow" value="true"/> 
</bean> 












以上是关于Could not get a resource from the pool的主要内容,如果未能解决你的问题,请参考以下文章

Could not get a resource from the pool 错误解决

[故障解决]Could not get a resource from the pool。

开发手记:JedisConnectionException: Could not get a resource from the pool

redis Could not get a resource from the pool 基本内容

java 连接 redis集群时报错:Could not get a resource from the pool

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool(示例代码