0

使用 java/Spring/Ibatis sqlserver 是数据库,datasourceorg.apache.commons.dbcp.BasicDataSource下面是源对象

<bean id="wssModelDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbcx.JtdsDataSource"/>
    <property name="url" value="com.wss.jdbc.ConnectionUrl=jdbc:jtds:sqlserver://x-x2/x_control_QA;appName=wss;sendStringParametersAsUnicode=false;loginTimeout=20;socketTimeout=180"/>
    <property name="username" value="xxx"/>
    <property name="password" value="xxx"/>
    <property name="maxActive" value="10"/>
    <property name="maxWait" value="10000"/>
  </bean>

在日志文件中,我们发现了以下异常。

--- Cause: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object]

堆栈跟踪如下

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, general error
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:118)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
        at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy.invoke(TransactionAwareDataSourceProxy.java:210)
        at .prepareStatement(Unknown Source)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:494)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:176)
        at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
        at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
        ... 196 more
Caused by: java.lang.InterruptedException
        at java.lang.Object.wait(Native Method)
        at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1112)
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
        ... 204 more
2012-10-15 04:29:57,258 [Thread-2] INFO  [ConnectionManagerImpl.java:58] : user[] Stopping managed instances...
2012-10-15 04:29:57,444 [http-bio-8000-exec-81187] INFO  [LoggingInterceptor.java:42] : user[] uri[/wss/security/login_submit.html] took[6.612] seconds
2012-10-15 04:29:57,451 [http-bio-8000-exec-81182] ERROR [LoginSubmitAction.java:121] : user[] Exception logging in[
--- The error occurred in ibatis/control_core.xml.
--- The error occurred while executing query.

我正在尝试使用带有用户凭据的 Jmeter http 登录请求作为参数来重现此错误,这让我可以成功登录,从而导致从控制器调用 DAO 层。

但问题是我尝试过使用 3 个 Jmeter 实例运行永远循环 100 个线程,但它没有重现问题?任何快速的想法我怎样才能重现这个问题?

4

1 回答 1

0

我使用 Jmeter 重现了这个错误,我创建了 httprequest 请求登录参数并启动了 5 个 JMeter 实例。终于能够重现这个问题。

于 2012-10-16T20:58:23.557 回答