-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate needs non connection pooling option for GAB users
PostPosted: Sat Sep 27, 2014 12:17 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:52 am
Posts: 34
This week i tried to use Hibernate 4.3.6.Final in a Google App Engine / Google Cloud Sql project and ran into a problem;

When starting up, Hibernate throws
Quote:
java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)

In earlier GAE/GCS projects i used Hibernate 4.3.0.Beta3 without any problems (with connection.pool_size = 0). The problem is the new implementation of the default connection pool DriverManagerConnectionProviderImpl in Hibernate. This connection pool tries to spawn new Threads with Executors.newSingleThreadScheduledExecutor;

Code:
executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(
        new Runnable() {...}
This is not allowed on Google App Engine;

This is not allowed on Google App Engine;

https://cloud.google.com/appengine/docs/java/
Quote:
A GAE Java application can create a new thread, but there are some restrictions on how to do it. These threads can't "outlive" the request that creates them.

The actual problem is the Hibernate configuration which doesn't allow the use of no connection pool. According to Google this connection pool is even not necessary on GAE/GCS;

https://cloud.google.com/sql/faq#connections
Quote:
How to best manage your database connections depends on your use case. For example, if the time to create a new database connection is greater than checking and reusing an existing connection, then we recommend you use connection pooling. Conversely, if the time to create a new connection is about the same as testing if an existing connection is alive and reusing it, then we recommend that you create a new connection to service each HTTP request, and reuse it for the duration of the request. In particular, the latter case may apply when you connect from Google App Engine to Google Cloud SQL.

summarized; we don't need connection pooling on GAE/GCS, but Hibernate doesn't provide a non connection pooling option out of the box.

Because of a tight schedule i went for a quick solution; i wrote my own version of DriverManagerConnectionProviderImpl. This version doesn't keep a administration of connections but just opens and closes connection on a call. There's some room for improvement because i should reuse the connection for the duration of the request ... Another solution would be the use of approved GAE Threads...

In my opinion Hibernate should provide the no pooling option for GAE/GCS developers...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.