Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » The "Require-Bundle" trick don't work with c3p0 pool
The "Require-Bundle" trick don't work with c3p0 pool [message #1007674] Wed, 06 February 2013 20:45 Go to next message
Anton Lem is currently offline Anton Lem
Messages: 11
Registered: January 2013
Junior Member
Imagine situation: I have a main WAB which uses the separated c3p0-bundle like a connection pool. WAB doesn't just use c3p0 but customises its connection by WAB's class. To work properly, c3p0-bundle class loader has to obtain this WAB's class. To open access to WAB's classes for c3p0 I wrote "Require-Bundle: com.springsource.com.mchange.v2.c3p0" in the WAB's MANIFEST. This solution is successfully working with the hibernate bundle, but c3p0 can't find the required class.
Could not create for find ConnectionCustomizer with class name 'com.liferay.portal.dao.jdbc.pool.c3p0.PortalConnectionCustomizer'. org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: com.liferay.portal.dao.jdbc.pool.c3p0.PortalConnectionCustomizer in KernelBundleClassLoader: [bundle=com.springsource.com.mchange.v2.c3p0_0.9.1.2]

I earlier just repacked the original c3p0-bundle to add Import of the required class package. This solution works but issues another kind of problem (http://www.eclipse.org/forums/index.php/mv/msg/452453/1006711/#msg_1006711). What is wrong in this situation with Require-bundle? Is there some other tricks to enforce the separated c3p0-bundle to find the required class inside main WAB?
Re: The "Require-Bundle" trick don't work with c3p0 pool [message #1007675 is a reply to message #1007674] Wed, 06 February 2013 21:27 Go to previous message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
I think you are looking at known Class.forName() issue.

c3p0 loads ConnectionCustomizer like this:
out = (ConnectionCustomizer) Class.forName( className ).newInstance();


Rad about it here: http://wiki.osgi.org/wiki/Avoid_Classloader_Hacks

What you want to do is to have a separate bundle that will publish a DataSource Service object, created with help of c3p0 or Apache BDCP. In your wab you import that DataSource service and use it without having to have a RequireBundle dependency on c3p0.

Services are much better way to organize your dependencies.

Regards,
Dmitry
Previous Topic:Running a wab on virgo nano + gemini web
Next Topic:How to get EclipseRT/Virgo option in preferences>server>runtime environments?
Goto Forum:
  


Current Time: Sat Aug 30 06:33:13 EDT 2014

Powered by FUDForum. Page generated in 0.07573 seconds