做程序每个人都会遇到不同的问题,也有不同的解决办法。先描述一下我遇到的问题:
项目模块化,用到了dubbo,提供者和消费者都部署好了,主要进行数据库查询工作,查询的数据放在列表List里,返回到前端显示。本人使用的连接池是druid,maxActive设置为10,一开始可以查询成功并正确显示(如果一开始就不成功,那就找其他原因吧),但是连续查询10次后就会查询失败,抛出异常:
com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout.
这两个数字一致,应该是短时间内,进行多次查询,连接池的可用连接数用完了,导致超时,检查发现是执行查询方法时
SqlSession session = sessionFactory.openSession();
创建的session没有关闭,加上session.close();
后,发现问题解决了。
话说spring整合mybatis,方法执行完之后不是会自动关闭session吗,这个是怎么回事呢,求解中。。。
异常详细如下:
Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method findPage in the service com.bestgg.sellergoods.service.BrandService. Tried 3 times of the providers [192.168.191.1:20881] (1/1) from the registry 192.168.191.130:2181 on the consumer 192.168.191.1 using the dubbo version 2.8.4. Last error is: Invoke remote method timeout. method: findPage, provider: dubbo://192.168.191.1:20881/com.bestgg.sellergoods.service.BrandService?anyhost=true&application=bestgg-manager-web&check=false&dubbo=2.8.4&generic=false&interface=com.bestgg.sellergoods.service.BrandService&methods=add,deleteBrand,findById,update,findPage,findAll&pid=6336&revision=1.0-SNAPSHOT&side=consumer×tamp=1547393907736, cause: Waiting server-side response timeout. start time: 2019-01-13 23:38:46.768, end time: 2019-01-13 23:38:47.769, client elapsed: 0 ms, server elapsed: 1001 ms, timeout: 1000 ms, request: Request [id=31, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=findPage, parameterTypes=[int, int], arguments=[1, 10], attachments={path=com.bestgg.sellergoods.service.BrandService, interface=com.bestgg.sellergoods.service.BrandService, version=0.0.0}]], channel: /192.168.191.1:1681 -> /192.168.191.1:20881] with root cause
com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2019-01-13 23:38:46.768, end time: 2019-01-13 23:38:47.769, client elapsed: 0 ms, server elapsed: 1001 ms, timeout: 1000 ms, request: Request [id=31, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=findPage, parameterTypes=[int, int], arguments=[1, 10], attachments={path=com.bestgg.sellergoods.service.BrandService, interface=com.bestgg.sellergoods.service.BrandService, version=0.0.0}]], channel: /192.168.191.1:1681 -> /192.168.191.1:20881
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:107)
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1. i n v o k e ( P r o t o c o l F i l t e r W r a p p e r . j a v a : 91 ) a t c o m . a l i b a b a . d u b b o . r p c . p r o t o c o l . I n v o k e r W r a p p e r . i n v o k e ( I n v o k e r W r a p p e r . j a v a : 53 ) a t c o m . a l i b a b a . d u b b o . r p c . c l u s t e r . s u p p o r t . F a i l o v e r C l u s t e r I n v o k e r . d o I n v o k e ( F a i l o v e r C l u s t e r I n v o k e r . j a v a : 77 ) a t c o m . a l i b a b a . d u b b o . r p c . c l u s t e r . s u p p o r t . A b s t r a c t C l u s t e r I n v o k e r . i n v o k e ( A b s t r a c t C l u s t e r I n v o k e r . j a v a : 227 ) a t c o m . a l i b a b a . d u b b o . r p c . c l u s t e r . s u p p o r t . w r a p p e r . M o c k C l u s t e r I n v o k e r . i n v o k e ( M o c k C l u s t e r I n v o k e r . j a v a : 72 ) a t c o m . a l i b a b a . d u b b o . r p c . p r o x y . I n v o k e r I n v o c a t i o n H a n d l e r . i n v o k e ( I n v o k e r I n v o c a t i o n H a n d l e r . j a v a : 52 ) a t c o m . a l i b a b a . d u b b o . c o m m o n . b y t e c o d e . p r o x y 0. f i n d P a g e ( p r o x y 0. j a v a ) a t c o m . b e s t g g . m a n a g e r . c o n t r o l l e r . B r a n d C o n t r o l l e r . f i n d P a g e ( B r a n d C o n t r o l l e r . j a v a : 32 ) a t s u n . r e f l e c t . G e n e r a t e d M e t h o d A c c e s s o r 37. i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 498 ) a t o r g . s p r i n g f r a m e w o r k . w e b . m e t h o d . s u p p o r t . I n v o c a b l e H a n d l e r M e t h o d . d o I n v o k e ( I n v o c a b l e H a n d l e r M e t h o d . j a v a : 222 ) a t o r g . s p r i n g f r a m e w o r k . w e b . m e t h o d . s u p p o r t . I n v o c a b l e H a n d l e r M e t h o d . i n v o k e F o r R e q u e s t ( I n v o c a b l e H a n d l e r M e t h o d . j a v a : 137 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . S e r v l e t I n v o c a b l e H a n d l e r M e t h o d . i n v o k e A n d H a n d l e ( S e r v l e t I n v o c a b l e H a n d l e r M e t h o d . j a v a : 110 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . R e q u e s t M a p p i n g H a n d l e r A d a p t e r . i n v o k e H a n d l e r M e t h o d ( R e q u e s t M a p p i n g H a n d l e r A d a p t e r . j a v a : 814 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . R e q u e s t M a p p i n g H a n d l e r A d a p t e r . h a n d l e I n t e r n a l ( R e q u e s t M a p p i n g H a n d l e r A d a p t e r . j a v a : 737 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . A b s t r a c t H a n d l e r M e t h o d A d a p t e r . h a n d l e ( A b s t r a c t H a n d l e r M e t h o d A d a p t e r . j a v a : 85 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . D i s p a t c h e r S e r v l e t . d o D i s p a t c h ( D i s p a t c h e r S e r v l e t . j a v a : 959 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . D i s p a t c h e r S e r v l e t . d o S e r v i c e ( D i s p a t c h e r S e r v l e t . j a v a : 893 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . p r o c e s s R e q u e s t ( F r a m e w o r k S e r v l e t . j a v a : 969 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . d o G e t ( F r a m e w o r k S e r v l e t . j a v a : 860 ) a t j a v a x . s e r v l e t . h t t p . H t t p S e r v l e t . s e r v i c e ( H t t p S e r v l e t . j a v a : 621 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . s e r v i c e ( F r a m e w o r k S e r v l e t . j a v a : 845 ) a t j a v a x . s e r v l e t . h t t p . H t t p S e r v l e t . s e r v i c e ( H t t p S e r v l e t . j a v a : 728 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . i n t e r n a l D o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 305 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . d o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 210 ) a t o r g . a p a c h e . t o m c a t . w e b s o c k e t . s e r v e r . W s F i l t e r . d o F i l t e r ( W s F i l t e r . j a v a : 51 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . i n t e r n a l D o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 243 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . d o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 210 ) a t o r g . s p r i n g f r a m e w o r k . w e b . f i l t e r . C h a r a c t e r E n c o d i n g F i l t e r . d o F i l t e r I n t e r n a l ( C h a r a c t e r E n c o d i n g F i l t e r . j a v a : 121 ) a t o r g . s p r i n g f r a m e w o r k . w e b . f i l t e r . O n c e P e r R e q u e s t F i l t e r . d o F i l t e r ( O n c e P e r R e q u e s t F i l t e r . j a v a : 107 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . i n t e r n a l D o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 243 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . d o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 210 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d W r a p p e r V a l v e . i n v o k e ( S t a n d a r d W r a p p e r V a l v e . j a v a : 222 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d C o n t e x t V a l v e . i n v o k e ( S t a n d a r d C o n t e x t V a l v e . j a v a : 123 ) a t o r g . a p a c h e . c a t a l i n a . a u t h e n t i c a t o r . A u t h e n t i c a t o r B a s e . i n v o k e ( A u t h e n t i c a t o r B a s e . j a v a : 502 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d H o s t V a l v e . i n v o k e ( S t a n d a r d H o s t V a l v e . j a v a : 171 ) a t o r g . a p a c h e . c a t a l i n a . v a l v e s . E r r o r R e p o r t V a l v e . i n v o k e ( E r r o r R e p o r t V a l v e . j a v a : 100 ) a t o r g . a p a c h e . c a t a l i n a . v a l v e s . A c c e s s L o g V a l v e . i n v o k e ( A c c e s s L o g V a l v e . j a v a : 953 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d E n g i n e V a l v e . i n v o k e ( S t a n d a r d E n g i n e V a l v e . j a v a : 118 ) a t o r g . a p a c h e . c a t a l i n a . c o n n e c t o r . C o y o t e A d a p t e r . s e r v i c e ( C o y o t e A d a p t e r . j a v a : 408 ) a t o r g . a p a c h e . c o y o t e . h t t p 11. A b s t r a c t H t t p 11 P r o c e s s o r . p r o c e s s ( A b s t r a c t H t t p 11 P r o c e s s o r . j a v a : 1041 ) a t o r g . a p a c h e . c o y o t e . A b s t r a c t P r o t o c o l 1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77) at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy0.findPage(proxy0.java) at com.bestgg.manager.controller.BrandController.findPage(BrandController.java:32) at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol 1.invoke(ProtocolFilterWrapper.java:91)atcom.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)atcom.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)atcom.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227)atcom.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)atcom.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)atcom.alibaba.dubbo.common.bytecode.proxy0.findPage(proxy0.java)atcom.bestgg.manager.controller.BrandController.findPage(BrandController.java:32)atsun.reflect.GeneratedMethodAccessor37.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:498)atorg.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)atorg.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:621)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:728)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)atorg.apache.coyote.AbstractProtocolAbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint S o c k e t P r o c e s s o r . r u n ( J I o E n d p o i n t . j a v a : 310 ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1142 ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor SocketProcessor.run(JIoEndpoint.java:310)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)atjava.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)