nginx+redis+tomcat,做反向代理配置,导致java报错,请问如何处理?

nginx+redis+tomcat,做反向代理配置,报jedis错误:Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool。redis数据库正常,这个jedis是一个jar包。不知道这个问题怎么解?

2019-09-06 08:34:53 [ ERROR ] [ Runtime Exception ] com.ivo.web.LoginController@60a2b94:public java.lang.String com.ivo.web.LoginController.ajaxCreate(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse):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:Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
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:140)
 at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:229)
 at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:57)
 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:177)
 at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
 at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85)
 at org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:131)
 at org.springframework.data.redis.core.DefaultBoundHashOperations.putAll(DefaultBoundHashOperations.java:85)
 at org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.saveDelta(RedisOperationsSessionRepository.java:778)
 at org.springframework.session.data.redis.RedisOperationsSessionRepository$RedisSession.access$000(RedisOperationsSessionRepository.java:670)
 at org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:388)
 at org.springframework.session.data.redis.RedisOperationsSessionRepository.save(RedisOperationsSessionRepository.java:245)
 at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.commitSession(SessionRepositoryFilter.java:245)
 at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.access$100(SessionRepositoryFilter.java:217)
 at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryResponseWrapper.onResponseCommitted(SessionRepositoryFilter.java:205)
 at org.springframework.session.web.http.OnCommittedResponseWrapper.doOnResponseCommitted(OnCommittedResponseWrapper.java:226)
 at org.springframework.session.web.http.OnCommittedResponseWrapper.checkContentLength(OnCommittedResponseWrapper.java:216)
 at org.springframework.session.web.http.OnCommittedResponseWrapper.access$200(OnCommittedResponseWrapper.java:37)
 at org.springframework.session.web.http.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:562)
 at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
 at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:316)
 at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:149)
 at java.io.OutputStreamWriter.close(OutputStreamWriter.java:233)
 at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:216)
 at com.ivo.system.util.Utf8StringHttpMessageConverter.writeInternal(Utf8StringHttpMessageConverter.java:76)
 at com.ivo.system.util.Utf8StringHttpMessageConverter.writeInternal(Utf8StringHttpMessageConverter.java:17)
 at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:179)
 at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)
 at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
 at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:189)
 at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:69)
 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:233)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167)
 at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Thread.java:745)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
 at redis.clients.util.Pool.getResource(Pool.java:50)
 at redis.clients.jedis.JedisPool.getResource(JedisPool.java:88)
 at redis.clients.jedis.JedisPool.getResource(JedisPool.java:12)
 at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:133)
 ... 70 more
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
 at redis.clients.jedis.Connection.connect(Connection.java:148)
 at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:75)
 at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1572)
 at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:69)
 at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
 at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
 at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
 at redis.clients.util.Pool.getResource(Pool.java:48)
 ... 73 more

3回答

刘康刘康  系统分析师 , 日志易
日志易zhuhaiqiangmichael1983赞同了此回答
看看链接池吧显示全部

看看链接池吧

收起
 2019-09-13
浏览385
aixchina 邀答
  • [此评论已删除]
    2019-09-16
  • <property name="maxActive" value="40"/> <property name="maxIdle" value="5"/> <property name="minIdle" value="2"/> <property name="maxWait" value="50000"/> <property name="removeAbandoned" value="true"/> <property name="logAbandoned" value="true"/> <property name="removeAbandonedTimeout" value="60"/> <bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> <property name="maxInactiveIntervalInSeconds" value="36000"/> </bean> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="10" /> <property name="maxTotal" value="100" /> <property name="minIdle" value="2" /> </bean> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host}" /> <property name="port" value="6379" /> <property name="database" value="11" /> <property name="timeout" value="3000"/> <property name="usePool" value="true"/> <property name="poolConfig" ref="jedisPoolConfig" /> </bean>
    2019-09-16
  • 这个是你的静态配置吧。。。。
    2019-09-17
  • java程式里配置的。请问您说的配置是?
    2019-09-20
priestpriest  系统架构师 , None
yinxin赞同了此回答
尝试一下操作:1、先ping 和telnet下看有没有问题2、检查下redis.conf配置文件,配置是否合理(比如:运行模式、绑定ip、)显示全部

尝试一下操作:
1、先ping 和telnet下看有没有问题
2、检查下redis.conf配置文件,配置是否合理(比如:运行模式、绑定ip、)

收起
 2019-11-13
顾黄亮顾黄亮  技术总监 , 苏宁消费金融有限公司
yinxin赞同了此回答
把bind 127.0.0.1改成bind 0.0.0.0 试一下,日志很明显了显示全部

把bind 127.0.0.1改成bind 0.0.0.0
试一下,日志很明显了

收起
 2019-09-16
浏览250
aixchina 邀答

问题状态

  • 发布时间:2019-09-12
  • 关注会员:4 人
  • 问题浏览:1992
  • 最近回答:2019-11-13
  • 关于TWT  使用指南  社区专家合作  厂商入驻社区  企业招聘  投诉建议  版权与免责声明  联系我们
    © 2019  talkwithtrend — talk with trend,talk with technologist 京ICP备09031017号-30