Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type(Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type)
Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type [message #1718390] Wed, 23 December 2015 09:19 Go to next message
Mohamed Anis Mekki is currently offline Mohamed Anis MekkiFriend
Messages: 3
Registered: December 2015
Junior Member
I am setting up a minimal working example where I use EclipseLink in a Java EE (JSF) project. My example works perfectly with the following configuration:

persistence.xml
<persistence
    version="2.0"
    ...
>
    <persistence-unit name="issat_PU_Local" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>pro.entity.Utilisateur</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/issat" />
            <property name="javax.persistence.jdbc.user" value="java" />
            <property name="javax.persistence.jdbc.password" value="JaVa" />
            <property name="eclipselink.logging.level.sql" value="FINE" />
            <property name="eclipselink.logging.parameters" value="true"/>
        </properties>
    </persistence-unit>
</persistence>


Since I don't want to use JTA I am using RESOURCE_LOCAL as transaction type and perfectly leaving with "manually" handling transaction inside my DAO.

I now want to use BoneCP connection pool with my example. How should I precisely modify my persistence.xml to do that?

I found many configuration examples in the internet using also Hibernate, but I want to stay with EclipseLink.
Re: Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type [message #1719039 is a reply to message #1718390] Mon, 04 January 2016 16:16 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1380
Registered: July 2009
Senior Member
JPA defines how to define datasources within the persistence unit in a standards way. See http://www.eclipse.org/eclipselink/documentation/2.5/solutions/tlandwls002.htm#BABCGGEJ for an example showing how to define the non-jta-datasource tag, giving the provider a datasource outside of any JTA managed transaction scope, which will be used for resource local transactions.

Re: Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type [message #1719090 is a reply to message #1719039] Tue, 05 January 2016 07:26 Go to previous messageGo to next message
Mohamed Anis Mekki is currently offline Mohamed Anis MekkiFriend
Messages: 3
Registered: December 2015
Junior Member
Thank you Chris for your reply. Allow me to take my question further:

I used to deploy Java EE applications to a light container (Apache Tomcat), I am now trying full Java EE compliant servers and I started looking at Apache Tomee (Plume version which supports among others EclipseLink).
I learned that with Apache Tomee data sources can be declared globally to the container (in tomee.xml configuration file), then possibly used by many applications (in stead of each time configuring "by hand" the data source per each application).
I also succeeded into using BoneCP as connection pool provider by configuring inherently the data source in tomee.xml, see the use of org.apache.openejb.bonecp.BoneCPDataSourceCreator in tomee.xml below:

<Resource id="jdbc/bonecp_resource_issat" type="DataSource">
	DataSourceCreator org.apache.openejb.bonecp.BoneCPDataSourceCreator
	JtaManaged true
	JdbcDriver com.mysql.jdbc.Driver
	JdbcUrl jdbc:mysql://localhost:3306/issat
	UserName java
	Password JaVa
	PartitionCount 2
	MinConnectionsPerPartition 5
	MaxConnectionsPerPartition 10
	ValidationQuery SELECT 1
</Resource>


If I understood correctly your suggestion: I can get rid of JTA by configuring my application's persistence.xml file as explained by the link your provided, while still using a data source globally defined in Apache Tomee and consequently while still having BoneCP in charge of the data pool.
Is my understanding correct ?

What if I want to use EclipseLink and BoneCP into an application to be deployed under a light container like Apache Tomcat, so using only the application's persistence.xml file to define my data source (and not using a "global" JNDI resource).
Is there a way to tell EclipseLink to use BoneCP as a connection pool provider ?

I'm pretty sure this is possible through Hibernate (I already did it with c3p0 connection pool provider), but could this be done without Hibernate and only with EclipseLink ?

[Updated on: Tue, 05 January 2016 08:06]

Report message to a moderator

Re: Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type [message #1719390 is a reply to message #1719090] Thu, 07 January 2016 15:36 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1380
Registered: July 2009
Senior Member
I'm not familiar with BoneCP and haven't really done any projects on the Tomcat variants either so maybe someone else might be able to come up with examples or help.

The non-jta-datasource tag tells the provider to look up the datasource from the context - this lookup is controlled through a EclipseLink server platform class. If you run into trouble, you could always make your own custom subclass to handle it how ever you need to, and then specify it using the eclipselink.target-server property http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_target_server.htm

Another alternative is that you can pass the datasource directly to EclipseLink as a persistence property as described here:
http://onpersistence.blogspot.com/2008/04/eclipselink-and-datasources.html

Hopefully this points you in the right direction.

Best Regards,
Chris
Re: Integrate BoneCP and EclipseLink with LOCAL_RESOURCE transaction-type [message #1719466 is a reply to message #1719390] Fri, 08 January 2016 08:45 Go to previous message
Mohamed Anis Mekki is currently offline Mohamed Anis MekkiFriend
Messages: 3
Registered: December 2015
Junior Member
Thank you very much Chris, I'll try "digging" in both directions you pointed out, and hopefully will come back with some feedback.
Previous Topic:Escaping ]]> in MOXy
Next Topic:(Resolved) EclipseLink 2.6.0 creates too many instances when join fetching ElementCollection
Goto Forum:
  


Current Time: Tue Mar 02 15:24:24 GMT 2021

Powered by FUDForum. Page generated in 0.02468 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top