我在karaf中的pax-jdbc池連接出現問題,我試圖通過 blueprint.xml注入一個Mysql DataSource(DS)到我的項目,爲了測試它,我已經構建了一個karaf命令,將DS注入karaf命令類 並使用該連接執行查詢。這沒關係,但問題是,當我執行命令了很多次, 每次執行創建DS的新實例和池連接無法打開到MySQL新連接,因爲 池已經達到了極限。karaf + pax-jdbc連接池已達到極限
我已經將我的代碼上傳到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
如果執行9次此命令「的MySQL連接」,將凍結karaf的提示,如果你打斷 執行就可以得到這個例外:
值java.sql.SQLException:在com.twim.OrmCommand.execute無法獲得在 org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:146)的連接,一般錯誤 (OrmCommand.java:53)在 org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83) 在 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.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406) at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)在在 org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)在 org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94) at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:270) at java。在 java.util.concurrent.locks.AbstractQueuedSynchronizer中的$ ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) java.lang.InterruptedException在 java.util中:lang.Thread.run(Thread.java:745)引起的。 concurrent.locks.AbstractQueuedSynchronizer $ ConditionObject.await(AbstractQueuedSynchronizer.java:2048) 在 org.apache.commons.pool2.impl.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:583) 在 org.apache.commons.po ol2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:442) 在 org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) 在 org.apache.commons.dbcp2.PoolingDataSource。的getConnection(PoolingDataSource.java:134) ...... 12多個
哇! @ christian-schneider,我無法相信這條線是我的問題,非常感謝。 :) – christmo