0

karaf の pax-jdbc のプール接続に問題があります。blueprint.xml を介して Mysql DataSource (DS) をプロジェクトに挿入しようとしています。テストのために、DS を挿入する karaf コマンドを作成しました。 karaf コマンド クラスを開き、その接続でクエリを実行します。問題はありませんが、コマンドを何度も実行すると、実行ごとに DS の新しいインスタンスが作成され、プール接続が MySQL への新しい接続を開くことができません。これは、プールが制限に達したためです。

このリンクでコードを github にアップロードしました: https://github.com/christmo/karaf-pax-jdbc。このプロジェクトでエラーが見つかった場合は、プル リクエストを送信できます。

このプロジェクトをテストするには、次のことができます。

1. Download karaf 4.0.4 or apache-karaf-4.1.0-SNAPSHOT
2. Copy the file karaf-pax-jdbc/etc/org.ops4j.datasource-my-ds.cfg to ${karaf}/etc, this file have the mysql 
   configuration change with your mysql configuration data.
4. Start mysql database engine
3. Start karaf -> cd ${karaf}/bin/; ./karaf
4. Add the repo of this project with this karaf command: feature:repo-add mvn:pax/features/1.0-SNAPSHOT/xml/features
5. Install the feature created for this project: feature:install mysql-test
6. Execute the command for test this problem: mysql-connection, this command only execute "Select 1" in mysql

このコマンド「mysql-connection」を 9 回実行すると、karaf のプロンプトがフリーズし、実行を中断すると、次の例外が発生する可能性があります。

java.sql.SQLException: 接続を取得できません。組織の com.twim.OrmCommand.execute(OrmCommand.java:53) の org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:146) で一般的なエラーが発生しました。 apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83) at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67) at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87) at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480) at org. org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406) org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108) org.apache.felix.gogo.runtime. org.apache.felix.gogo.runtime.Closure の Closure.execute(Closure.java:182)。org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java: 270) java.lang.Thread.run(Thread.java:745) で 原因: java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) での java.lang.InterruptedException java.util で.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2048) at org.apache.commons.pool2.impl.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:583) at org.apache.commons.pool2.impl.GenericObjectPool .borrowObject(GenericObjectPool.java:442) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) at org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:134) ... 12 詳細

4

1 に答える 1

2

コードの問題は行にありSystem.out.println("--DS--: " + ds.getConnection());ます。

そこで接続を作成しますが、決して閉じません。したがって、すべての呼び出しでプールを空にします。

于 2016-03-27T21:23:23.420 に答える