title: JDBC connection pool compatible with App Engine
body: <p><em>Note: I know about <a href="https://stackoverflow.com/questions/21457736/connection-pool-on-app-engine-with-cloud-sql">this</a> thread but it is quite old and moreover, the solution did not work for me.</em></p>
  
  <p>I am using App Engine along with Cloud SQL and I would like to share a pool of open connections between all of the application's current users. I have tried several connection pool implementations and they all work perfectly with the local development server, however, when deployed to the cloud, they fail. I suppose that the reason is App Engine's restricted "sandbox" environment. Does anyone know about JDBC connection pool working on App Engine?</p>
  
  <p><strong>Apache Commons DBCP</strong></p>
  
  <pre><code>...
  Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.dbcp2.PoolableConnection
  at com.google.appengine.runtime.Request.process-a49d46300800d0ca(Request.java)
  at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:254)
  at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2162)
  at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2148)
  at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:1903)
  at org.apache.commons.dbcp2.BasicDataSource$PaGetConnection.run(BasicDataSource.java:2267)
  at org.apache.commons.dbcp2.BasicDataSource$PaGetConnection.run(BasicDataSource.java:2263)
  at java.security.AccessController.doPrivileged(AccessController.java:63)
  at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1404)
  ...
  </code></pre>
  
  <p><strong>Tomcat JDBC Connection Pool</strong></p>
  
  <pre><code>...
  Caused by: java.lang.SecurityException: Unable to get members for class org.apache.tomcat.jdbc.pool.DataSource
  
  ...
  
  Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  ... 45 more
  Caused by: java.lang.NoClassDefFoundError: javax/management/MalformedObjectNameException
  at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2517)
  ... 45 more
  Caused by: java.lang.ClassNotFoundException: javax.management.MalformedObjectNameException
  ... 45 more
  </code></pre>
  
  <p><strong>HikariCP</strong></p>
  
  <pre><code>...
  java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
  at java.security.AccessController.checkPermission(AccessController.java:565)
  at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
  at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
  at java.lang.Thread.init(Thread.java:378)
  at java.lang.Thread.&lt;init&gt;(Thread.java:527)
  at com.zaxxer.hikari.util.DefaultThreadFactory.newThread(DefaultThreadFactory.java:32)
  at java.util.concurrent.ThreadPoolExecutor$Worker.&lt;init&gt;(ThreadPoolExecutor.java:591)
  at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:922)
  at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1591)
  at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:305)
  at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(ScheduledThreadPoolExecutor.java:542)
  at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:161)
  at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:114)
  at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:102)
  ...
  </code></pre>
  
  <p><strong>Vibur DBCP</strong></p>
  
  <pre><code>...
  Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
  at java.security.AccessController.checkPermission(AccessController.java:565)
  at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
  at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
  at java.lang.Thread.init(Thread.java:378)
  at java.lang.Thread.&lt;init&gt;(Thread.java:448)
  at org.vibur.objectpool.reducer.SamplingPoolReducer.&lt;init&gt;(SamplingPoolReducer.java:78)
  at org.vibur.dbcp.pool.PoolOperations$PoolReducer.&lt;init&gt;(PoolOperations.java:88)
  at org.vibur.dbcp.pool.PoolOperations$PoolReducer.&lt;init&gt;(PoolOperations.java:86)
  at org.vibur.dbcp.pool.PoolOperations.&lt;init&gt;(PoolOperations.java:79)
  at org.vibur.dbcp.ViburDBCPDataSource.start(ViburDBCPDataSource.java:197)
  ....
  </code></pre>
  
  <p><strong>c3p0</strong></p>
  
  <pre><code>...
  Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
  at java.security.AccessController.checkPermission(AccessController.java:565)
  at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
  at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
  at java.lang.Thread.init(Thread.java:378)
  at java.lang.Thread.&lt;init&gt;(Thread.java:487)
  ...
  </code></pre>