一些操作后,使用hibernate和c3p0的JSF应用程序冻结

时间:2013-09-24 13:34:45

标签: hibernate c3p0

我在JSF 2.0应用程序中使用hibernate 4.2.4和c3p0 0.9.2.1。一切正常,但如果5个用户同时在应用程序内部执行某些操作,则会在几分钟后冻结。仍然可以访问同一容器内的其他应用程序(portlet),CPU和RAM的使用是正常的。

也许c3p0连接池的所有连接都在使用中,并且在使用后不会被释放?!但是如果这是问题我怎么检查呢?

stackoverflow.com上的一些主题告诉使用unreturnedConnectionTimeoutdebugUnreturnedConnectionStackTraces。我是否必须将它像下面这样放入我的hibernate.cfg.xml中?

<property name="com.mchange.v2.c3p0.unreturnedConnectionTimeout">5</property>
<property name="com.mchange.v2.c3p0.debugUnreturnedConnectionStackTraces">true</property>

我的hibernate.cfg.xml是:

<property name="current_session_context_class">thread</property>

<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>

1 个答案:

答案 0 :(得分:0)

所以,首先:两个maxPoolSize(hibernate.c3p0.max_size)并不是一个好主意。它应该“有效”,但如果您有任何重要的并发访问权限,则需要等待很长时间。

重新配置语法:它更像是......

<property name="hibernate.c3p0.unreturnedConnectionTimeout">5</property>
<property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>

通过检查池初始化时的配置转储(在INFO)验证您想要的c3p0配置。

或者,使用JMX在冻结期间检查池。