操作redis异常:NoSuchElementException: Unable to validate object

项目中使用redis缓存,但我始终连接不上redis服务器,从本地能ping通,用redis桌面版客户端也能连接上.报错信息如下:

Root Cause

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
	redis.clients.util.Pool.getResource(Pool.java:50)
	redis.clients.jedis.JedisPool.getResource(JedisPool.java:86)
	net.shopnc.common.util.ShiroRedisHelper.set(ShiroRedisHelper.java:63)
	net.shopnc.shiro.cluster.CustomShiroSessionDao.update(CustomShiroSessionDao.java:32)
	net.shopnc.shiro.cluster.CustomShiroSessionDao.doCreate(CustomShiroSessionDao.java:67)
	org.apache.shiro.session.mgt.eis.AbstractSessionDAO.create(AbstractSessionDAO.java:116)
	org.apache.shiro.session.mgt.DefaultSessionManager.create(DefaultSessionManager.java:177)
	org.apache.shiro.session.mgt.DefaultSessionManager.doCreateSession(DefaultSessionManager.java:158)
	org.apache.shiro.session.mgt.AbstractValidatingSessionManager.createSession(AbstractValidatingSessionManager.java:136)
	org.apache.shiro.session.mgt.AbstractNativeSessionManager.start(AbstractNativeSessionManager.java:59)
	org.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:121)
	org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:336)
	org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:312)
	org.apache.shiro.web.util.WebUtils.saveRequest(WebUtils.java:606)
	org.apache.shiro.web.filter.AccessControlFilter.saveRequest(AccessControlFilter.java:208)
	org.apache.shiro.web.filter.AccessControlFilter.saveRequestAndRedirectToLogin(AccessControlFilter.java:191)
	org.apache.shiro.web.filter.authc.FormAuthenticationFilter.onAccessDenied(FormAuthenticationFilter.java:168)
	org.apache.shiro.web.filter.AccessControlFilter.onAccessDenied(AccessControlFilter.java:133)
	org.apache.shiro.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:162)
	org.apache.shiro.web.filter.PathMatchingFilter.isFilterChainContinued(PathMatchingFilter.java:203)
	org.apache.shiro.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:178)
	org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:131)
	org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause

java.util.NoSuchElementException: Unable to validate object
	org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:506)
	org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
	redis.clients.util.Pool.getResource(Pool.java:48)
	redis.clients.jedis.JedisPool.getResource(JedisPool.java:86)
	net.shopnc.common.util.ShiroRedisHelper.set(ShiroRedisHelper.java:63)
	net.shopnc.shiro.cluster.CustomShiroSessionDao.update(CustomShiroSessionDao.java:32)
	net.shopnc.shiro.cluster.CustomShiroSessionDao.doCreate(CustomShiroSessionDao.java:67)
	org.apache.shiro.session.mgt.eis.AbstractSessionDAO.create(AbstractSessionDAO.java:116)
	org.apache.shiro.session.mgt.DefaultSessionManager.create(DefaultSessionManager.java:177)
	org.apache.shiro.session.mgt.DefaultSessionManager.doCreateSession(DefaultSessionManager.java:158)
	org.apache.shiro.session.mgt.AbstractValidatingSessionManager.createSession(AbstractValidatingSessionManager.java:136)
	org.apache.shiro.session.mgt.AbstractNativeSessionManager.start(AbstractNativeSessionManager.java:59)
	org.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:121)
	org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:336)
	org.apache.shiro.subject.support.DelegatingSubject.getSession(DelegatingSubject.java:312)
	org.apache.shiro.web.util.WebUtils.saveRequest(WebUtils.java:606)
	org.apache.shiro.web.filter.AccessControlFilter.saveRequest(AccessControlFilter.java:208)
	org.apache.shiro.web.filter.AccessControlFilter.saveRequestAndRedirectToLogin(AccessControlFilter.java:191)
	org.apache.shiro.web.filter.authc.FormAuthenticationFilter.onAccessDenied(FormAuthenticationFilter.java:168)
	org.apache.shiro.web.filter.AccessControlFilter.onAccessDenied(AccessControlFilter.java:133)
	org.apache.shiro.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:162)
....

项目中redis配置:

redis.host=*******
redis.port=***
redis.timeout=5000
redis.password=***
//服务器配置不知道

在网上搜了很多资料都解决不了,最后把Tomcat服务器删了,重新解压一个,就好了.感觉很多时候项目的出错解决不了的时候就把Tomcat换个新的.

你可能感兴趣的:(成神之路)