A ResourcePool could not acquire a resource from its primary factory or source.

银河星沙 发布于 2014/09/04 09:01
阅读 5K+
收藏 1

 今天做SSH整合(struts2.3.16.3 + spring3.2+ hibernate3.6):

1.spring + hibernate 测试OK

2.spring + struts 测试OK

3.直接测试 service的方法,OK


Action中调用service的方法,连接不到数据库,报错:

Struts has detected an unhandled exception:

com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.


根据网上的方案等等

1.c3p0-0.9.5-pre8 降到 c3p0-0.9.5-pre5

2.struts2.3.16.3 降到 struts2.1.8.1

3.修改c3p0的一些属性;

4.Tomcat8.0glassfish4.0运行;

5.重启IDE或电脑;


错误依旧。


c3p0源码中:


com/mchange/v2/resourcepool/BasicResourcePool.java 1442行:

if (force_kill_acquires)

throw new CannotAcquireResourceException("A ResourcePool could not acquire a resource from its primary factory or source.");


还有以下方法,终止所有挂起的请求:

// this is designed as a response to a determination that our resource source is down.

// rather than declaring ourselves broken in this case (as we did previously), we

// kill all pending acquisition attempts, but retry on new acqusition requests.

private synchronized void forceKillAcquires() throws InterruptedException

{

........//

}


貌似是超时?为什么在Action中调用service的方法,才报错?


Spirng配置文件中,c3p0的设置:


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>

<property name="dataSource">

<bean class="com.mchange.v2.c3p0.ComboPooledDataSource">

<property name="jdbcUrl" value="${jdbcUrl}"></property>

<property name="driverClass" value="${driverClass}"></property>

<property name="user" value="${username}"></property>

<property name="password" value="${password}"></property>

<property name="initialPoolSize" value="3"></property>

<property name="minPoolSize" value="3"></property>

<property name="maxPoolSize" value="12"></property>

<property name="acquireIncrement" value="3"></property>

<property name="maxStatements" value="8"></property>

<property name="maxStatementsPerConnection" value="5"></property>

<property name="maxIdleTime" value="1800"></property>

</bean>

</property>

</bean>

谢谢!

加载中
返回顶部
顶部