We ran into similar issues (DBCP as well).  Our solution was to create a bundle 
that embedded (Bundle-Classpath) JTDS and DBCP into a single bundle so that 
they shared classpath.  From there you can export the necessary packages so any 
other bundle may create the DataSource/Connection instances in the JDBC 
standard way since they are now in a single classloader.

JDBC standard isn't well suited to OSGI.  OSGI Enterprise spec has a 
DataSourceFactory to help address this, that unfortunately very few 
implementations exist or integrate with.

-----Original Message-----
From: Reuben Garrett [mailto:reubengarr...@gmail.com] 
Sent: Wednesday, March 28, 2012 11:37 AM
To: users@camel.apache.org
Subject: C3P0 cannot load Jtds Driver in OSGi env

raad,

i'm not sure this is directly related to camel, but it looks like you're using 
a DriverManager-based connection pool within an OSGi environment.  i haven't 
used c3p0 before, but i do use Apache Commons DBCP and had a similar issue with 
class loading problems.  i believe i tracked it down to a call to 
Class.forName, which doesn't usually work nicely in OSGi.

my solution was to subclass the connection pool and directly reference the 
driver class (e.g., make a JtdsDataSource).

not the most elegant solution, but it worked for me.

~ Reuben

On Wednesday, March 28, 2012, raad wrote:

>  So i have wrapped the Jtds and c3p0 jars under install wrap command 
> and I still get the following when connection is being established:
>
>
> 13:37:14,941 | WARN  | er$PoolThread-#1 | DriverManagerDataSource  | 
> 268 - com.mchange.v2.c3p0 - 0.9.1.2 | Could not load driverClass 
> net.sourceforge.jtds.jdbc.Driver
> java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver not 
> found by com.mchange.v2.c3p0 [268]
>
>  at 
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
>        at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>

Reply via email to