[ https://issues.apache.org/jira/browse/DBCP-214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bernd Kolb updated DBCP-214: ---------------------------- Attachment: BasicDataSource.java Version: 1.2.2 Class: org.apache.commons.dbcp.BasicDataSouce Method: protected synchronized DataSource createDataSource() (changes made between //### START CHANGE ### and //### END CHANGE ### Changed code: //### START CHANGE ### Class driverFromCCL = null; if (driverClassName != null) { try { try { Class.forName(driverClassName); }catch (ClassNotFoundException e) { driverFromCCL = Thread.currentThread().getContextClassLoader().loadClass(driverClassName); } } catch (Throwable t) { String message = "Cannot load JDBC driver class '" + driverClassName + "'"; logWriter.println(message); t.printStackTrace(logWriter); throw new SQLNestedException(message, t); } } // Create a JDBC driver instance Driver driver = null; try { if (driverFromCCL!= null) { // Usage of drivermanager is not possible, as it does not respect the ContextClassLoader driver = (Driver) driverFromCCL.newInstance(); if (!driver.acceptsURL(url)) { new SQLException("No suitable driver", "08001"); } }else { driver = DriverManager.getDriver(url); } //### END CHANGE ### If you need more information, please let me know Cheers, Bernd > Basic datasource should respect the context classloader > ------------------------------------------------------- > > Key: DBCP-214 > URL: https://issues.apache.org/jira/browse/DBCP-214 > Project: Commons Dbcp > Issue Type: Bug > Affects Versions: 1.2.2 > Reporter: Bernd Kolb > Fix For: 1.3 > > Attachments: BasicDataSource.java > > > I tried to use DBCP in an OSGi environment. This this not possible at the > moment, as OSGi uses different classloaders and DBCP does not respect this. > The easiest way to solve this problem would be to use the contextclassloader > in case of a ClassNotFoundException -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]