连接池使用Glassfish和Apache DBCP与Spring挂起

时间:2010-04-15 14:56:39

标签: spring glassfish apache-commons-dbcp

我们有一个Spring应用程序,它使用Apache DBCP进行连接池。我们的应用程序已经生产了近一年没有任何问题。但是,在过去几周内,该应用程序已冻结多次。 (通过冻结,我的意思是没有处理请求。)通过重新启动托管应用程序的Glassfish域来暂时解决问题。

我们正在监视此应用程序的内存(堆+非堆)和CPU利用率。这里似乎没有什么不寻常的。但是,我们注意到,当我们重新启动域时,我们会在日志文件中收到类似于此帖子底部的异常消息。

我指出我们正在使用DBCP,因为每个NPE都会在堆栈顶部报告borrowObject方法。在任何应用程序关闭期间,它们中的每一个都在相同的毫秒内发生。

我们注意到过去发生了一些这样的事情(关闭了这样的NPE),但是当应用程序冻结时,总会有五个。这个,我们不相信巧合,是处理对应用程序的请求的相同数量的HTTPSSLWorkerThreads。

如果有人知道造成这种情况的原因,以及如何解决这个问题,那将非常感谢帮助。

[#|2009-09-27T12:17:12.209-0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-443-4;_RequestID=25b115cb-de08-4ad4-bfdb-f76eb13b4bbe;|StandardWrapperValve[spring-dispatcher]: PWC1406: Servlet.service() for servlet spring-dispatcher threw exception
java.lang.NullPointerException
  at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:788)
  at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
  at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
  at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:552)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:616)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:645)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:653)
  at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:685)
  at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:187)
  at stimpl.dao.ProjectDAO.getSearchResults(ProjectDAO.java:153)
  at stimpl.service.StimPlService.getSearchResults(StimPlService.java:69)
  at stimpl.mvc.search.ShowResultsController.handleRequestInternal(ShowResultsController.java:44)
  at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
  at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
  at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  at org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
  at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
  at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
  at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
  at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
  at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
  at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
  at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
  at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
  at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
  at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
  at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
  at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
|#]

2 个答案:

答案 0 :(得分:1)

不幸的是,DBCP臭名昭着,尽管最近还有重写努力。或者,您可以尝试使用(更快)不同的池,例如BoneCP:http://jolbox.com

答案 1 :(得分:1)

如果其他人偶然发现了这个问题,答案是here