Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Could not load driverClass oracle.jdbc.OracleDriver(Could not load driverClass oracle.jdbc.OracleDriver)
Could not load driverClass oracle.jdbc.OracleDriver [message #674610] Fri, 27 May 2011 14:47 Go to next message
supercube Missing name is currently offline supercube Missing nameFriend
Messages: 11
Registered: December 2010
Junior Member
Hello all,

I have a multiple bundle web app deployed on Virgo 2.1.0.

I am using com.mchange.v2.c3p0.ComboPooledDataSource in a bundle that is accessed by other bundles when they need to get a cached Datasource to perform database querying.
Here is a snippet from my service that creates the connection pool:

DataSource createDataSource(JdbcURL jdbcURL) throws DatasourceException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setJdbcUrl(jdbcURL.getUrl());
    dataSource.setMinPoolSize(minConnections);
    dataSource.setMaxPoolSize(maxConnections);
    dataSource.setDriverClass("oracle.jdbc.OracleDriver");
    return dataSource;
}


Other services take this dataSource, create a JdbcTemplate (new JdbcTemplate(dataSource)) and attempt to exectue queries and stored procedures.

However, they throw the below stacktrace (this is a snippet I have attached fuller logs).

Everything works fine if I use a SimpleDriverDataSource instead of ComboPooledDataSource. Additionally, I can use this ComboPooledDataSource and successfully perform queries in JUnit tests outside of the OSGI.


2011-05-26 15:40:57.568] pool-1-thread-1 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 2so7yk8gcrv70a193od6o|a0ebc2, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2so7yk8gcrv70a193od6o|a0ebc2, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:oracle:thin:[actual connection url removed by supercube], maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
[2011-05-26 15:40:57.584] chronousRunner$PoolThread-#0 com.mchange.v2.c3p0.DriverManagerDataSource Could not load driverClass oracle.jdbc.OracleDriver org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: oracle.jdbc.OracleDriver in KernelBundleClassLoader: [bundle=c3p0-0.9.1.2_0.0.0]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:139)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:100)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:117)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:135)
... 12 common frames omitted
Re: Could not load driverClass oracle.jdbc.OracleDriver [message #674676 is a reply to message #674610] Fri, 27 May 2011 20:32 Go to previous messageGo to next message
Arief Bastian is currently offline Arief BastianFriend
Messages: 7
Registered: May 2011
Junior Member
Hi,

I've found my self in similar condition, following is the solution I used...

Bundles which you need are:

  1. Oracle JDBC Driver Bundle, there was Oracle JDBC version 10.2.0.2 from EBR, but now it's gone. Other alternative is to wrap your Oracle JDBC Driver using bundlor utilities
  2. C3P0 Bundle, I use com.springsource.com.mchange.v2.c3p0 from EBR
  3. a Pooling DataSource service Bundle, with the following item on its META-INF/MANIFEST.MF
    ...
    Fragment-Host: com.springsource.com.mchange.v2.c3p0
    Import-Package: com.mchange.v2.c3p0;version="[0.9.1.2, 0.9.1.2]",javax
     .sql;version="0",oracle.jdbc.driver
    ...
    



Hope this help

Abbas
Re: Could not load driverClass oracle.jdbc.OracleDriver [message #677533 is a reply to message #674676] Wed, 08 June 2011 18:38 Go to previous message
supercube Missing name is currently offline supercube Missing nameFriend
Messages: 11
Registered: December 2010
Junior Member
Thanks for the help.
My bundle has several imported packages as shown below.
When I added the format host line I got lots of constraint conflicts as shown below.

My solution was to modify the C3P0 jar file's Manifest.mf directly, including my oracle driver package in the "Import Packages" section - I was surprised that it was not included there already. I do see it in the Apache Commons connection pooling jar.


Excerpt from my manifest.mf:

Import-Package: org.hibernate.validator;version="${hibernate.validator.version.range}",
oracle.jdbc
Import-Template: ...,org.springframework.*;version="${spring.version.range}"
Import-Bundle: org.springframework.core;version="${spring.version.range}"


============================


Excerpt from stack trace after including Fragment-Host in manifest.mf:

Cannot satisfy constraints for bundle 'com.cme.star.service.datasource' version '2.0.0.SNAPSHOT'. Cannot resolve: com.cme.star.service.datasource
Resolver report:
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Constraint conflict:
Import-Package: javax.annotation; version="0.0.0"
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Constraint conflict:
Import-Package: org.apache.commons.pool.impl; version="0.0.0"
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Constraint conflict:
Import-Package: org.springframework.beans.factory.annotation; version="[3.0.0,3.1.0)"
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Constraint conflict:
Import-Package: com.cme.star.common; version="[2.0.0,2.1.0)"
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Constraint conflict:
Import-Package: org.apache.commons.jocl; version="0.0.0"
The fragment could not be resolved because of a constraint conflict with a host, possibly because the host is already resolved. The affected fragment is com.cme.star.service.datasource_2.0.0.SNAPSHOT
Possible hosts:
c3p0-0.9.1.2_0.0.0 (resolved)
Previous Topic:Package resolve conflict while adding spring service to WAR
Next Topic:Virgo 3.0 plan date
Goto Forum:
  


Current Time: Thu Mar 28 21:48:52 GMT 2024

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

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

Back to the top