| Summary: | Connection pooling does not work for connections created via Gemini JPA | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | GianMaria Romanato <gm.romanato> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | CLOSED FIXED | QA Contact: | |||||||
| Severity: | enhancement | ||||||||
| Priority: | P2 | CC: | eclipselink.orm-inbox, edufrazao, juergen.kissner, ronny.voelker, tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | All | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
GianMaria Romanato
What does your persistence.xml look like? Created attachment 215785 [details]
Sample persistence.xml file
The attached sample persistence.xml file contains a JDBC URL.
When I noticed that pooling was disabled I also tried using a different set of properties (those documented in the Javadoc of the Gemini DBAccess implementation for Derby which I am pasting below) hoping that the system would create a datasource instead of using the driver. But unfortunately this did not work: if I omit the URL parameter I get a runtime exception complaining that the URL is missing.
/**
* A factory for creating Derby network data sources. The properties specified
* in the create methods determine how the created object is configured.
*
* Sample code for obtaining a Derby network data source:
*
* ServiceTracker tracker =
* new ServiceTracker(context, DataSourceFactory.class.getName(), null);
* tracker.open();
* DataSourceFactory dsf = (DataSourceFactory) tracker.getService();
* Properties props = new Properties();
* props.put(DataSourceFactory.JDBC_SERVER_NAME, "localhost");
* props.put(DataSourceFactory.JDBC_PORT_NUMBER, "1527");
* props.put(DataSourceFactory.JDBC_DATABASE_NAME, "myDB");
* props.put(DataSourceFactory.JDBC_USER, "mike");
* props.put(DataSourceFactory.JDBC_PASSWORD, "password");
* DataSource ds = dsf.createDataSource(props);
*
* This service also supports a URL-based data source. The following 3 properties
* can be provided instead of the 5 properties above:
*
* props.put(DataSourceFactory.JDBC_URL, "jdbc:derby://localhost:1527/myDB");
* props.put(DataSourceFactory.JDBC_USER, "mike");
* props.put(DataSourceFactory.JDBC_PASSWORD, "password");
*/
public class ClientDataSourceFactory extends AbstractDataSourceFactory {
Changing this to a Gemini JPA Enhancement request. At the moment, Gemini will build a data source from the connection information you provide and pass it in to EclipseLink as a non-jta-datasource. When EclipseLink is provided a datasource, it makes use of that datasource and allow it to manage itself. Gemini could provide an option that allowed EclipseLink to manage its own datasources for cases where EclipseLink has access to all the necessary classes. You mentioned that when "EclipseLink is provided a datasource, it makes use of that datasource and allow it to manage itself". Is there an OSGi-friendly way to configure EclipseLink so that it obtains a datasource from the container? So far the only option I am aware of consists in programmatically obtaining the datasource and passing it to EclipseLink via the properties map... In my humble opinion the importance of this issue should not be lowered from major to enhancement, because the lack of proper pooling makes Gemini JPA practically not usable for production. If you add that Gemini JPA supports only Eclipse Link, that it is intended to provide the implementation of the OSGi blueprints and that there is no workaround to enable pooling other than dropping Gemini JPA and going for a different approach, I believe that this issue at presents makes Gemini JPA almost useless. The gemini folks investigated the best way to expose a JDBC driver to EclipseLink and it turns out that our best option may be within EclispeLink after all.
Gemini makes RESOURCE_LOCAL entity managers that have JDBC properties work by wrapping them in its own datasource implementation and passing them back to EclipseLink. That datasource implementation is not pooled.
We examined the EclipseLink code and it appears as though EclipseLink could provide a property that allows it to do its own pooling of data sources.
The suggested change is in EntityManagerSetupImpl.updateLogins -> roughly the code mentioned above.
// mainDatasource is guaranteed to be non null - TODO: No it is not, if they did not set one it is null, should raise error, not null-pointer.
if (!(login.getConnector() instanceof JNDIConnector)) {
JNDIConnector jndiConnector;
if (mainDatasource instanceof DataSourceImpl) {
//Bug5209363 Pass in the datasource name instead of the dummy datasource
jndiConnector = new JNDIConnector(((DataSourceImpl)mainDatasource).getName());
} else {
jndiConnector = new JNDIConnector(mainDatasource);
}
login.setConnector(jndiConnector);
/****
NEW CODE HERE
****/
if (!<ECLIPSELINK_USE_DATASOURCE_FOR_INTERNAL_POOL_PROPERTY>){
login.setUsesExternalConnectionPooling(true);
}
}
I still consider this an enhancement but am planning on targetting it for our upcoming 2.4 release so we can investigate this solution. If the solution is much more complex than above, it will likely have to be deferred.
Thank you very much for the effort you put in Eclipse Link and for your availability to listen to requests from your users, this is really what makes the Eclipse community so special. By the way, I guess the change should be login.setUsesExternalConnectionPooling(false) rather then true I'll keep fingers crossed hoping that this fix will land in the 2.4 release. Hi folks. Any progress on this issue? How can we use Gemini JPA in production without a pooled datasource? The only workaround is inject a ready pooled datasource via properties map? FYI: Gemini has an open bug for JTA integration https://bugs.eclipse.org/bugs/show_bug.cgi?id=356508 Missed 2.5.0. Deferring. Still no pooling when Eclipselink is used with Gemini JPA ? If this is still the case, I believe you took too early the decision to deprecate EclipseLink OSGi support in favor of Gemini JPA as stated here: http://wiki.eclipse.org/EclipseLink/Examples/OSGi "The OSGi support provided by EclipseLink is deprecated and has been replaced by the Gemini JPA project." Created attachment 231263 [details]
diff file with proposed changes
Attaching diff file with proposed changes.
With this change, Gemini users should specify the following persistence unit property to get pooling.
<property name="eclipselink.connection-pool.force-internal-pool" value="true"/>
Currently discussing with Gemini group what version of EclipseLink makes this change available.
Fix described above checked into 2.5.1 and trunk This feature will not added on version 2.4? How are you dependant on 2.4.x? Well... 2.5.0 is RC2. I think that it will be released soon right? No problem in this case. I can wait. After that, I can upgrade my projects to 2.5.1! Thanks by your effort Tom!! The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |