spring和redis整合异常整理
2016-09-14 11:07
351 查看
记录
解决方法:
我这里是因为配置了redi连接密码,但在配置文件中没有写
另一种是网上说可能是多个连接client中有一个连接失败或超时导致的,把配置中的
1、Unable to validate object
异常信息如下:org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:198) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:345) at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128) at org.springframework.data.redis.core.RedisConnectionUtils.bindConnection(RedisConnectionUtils.java:66) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:187) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:164) at org.springframework.data.redis.core.RedisTemplate.hasKey(RedisTemplate.java:639) at ssh.RedisUtilTest.test2(RedisUtilTest.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) 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:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:51) at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226) at redis.clients.jedis.JedisPool.getResource(JedisPool.java:16) at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:191) ... 36 more Caused by: java.util.NoSuchElementException: Unable to validate object at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:506) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) at redis.clients.util.Pool.getResource(Pool.java:49) ... 39 more
解决方法:
我这里是因为配置了redi连接密码,但在配置文件中没有写
redis.pass=导致的,所以加上密码即可
另一种是网上说可能是多个连接client中有一个连接失败或超时导致的,把配置中的
testOnBorrow改为
false好像就可以解决,但我没遇到过,所以不知道其真实性。
相关文章推荐
- Redis + Jedis + Spring整合遇到的异常(转)
- jedis,spring-redis-data 整合使用,版本问题异常以及解决。
- jedis,spring-redis-data 整合使用,版本问题异常
- 重新整理struts2与spring整合相关知识
- Spring2.5.6整合hibernate3遇到的异常3
- hibernate 和spring整合常见异常
- Spring整合iBatis之一:整合中遇到的异常总结
- hibernateDao整理(未整合spring)
- struts2整合spring出现的Unable to instantiate Action异常
- Spring2.5.6整合hibernate3遇到的异常1
- Spring2.5.6整合hibernate3遇到的异常2
- spring和redis的整合
- JDK6+Tomcat6+MyEclipse6,整合Struts,Spring,Hibernate出现异常
- spring整合hibernate时的getHibernateTemplate()异常
- hibernate4 和 spring3 整合注意事项 否则java.lang.NoSuchMethodError异常 - lihui_yy
- spring redis整合(一)
- Spring3.0 整合 Struts2.0 出现的异常
- Spring2.5与jpa整合异常
- spring redis整合
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedExcept