You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Bernd Kolb (JIRA)" <ji...@apache.org> on 2007/04/10 18:35:32 UTC
[jira] Created: (DBCP-214) Basic datasource should respect the
context classloader
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
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (DBCP-214) Basic datasource should respect the
context classloader
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DBCP-214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz updated DBCP-214:
-----------------------------
Fix Version/s: 1.3
Patches welcome
> 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
>
>
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (DBCP-214) Basic datasource should respect the
context classloader
Posted by "Bernd Kolb (JIRA)" <ji...@apache.org>.
[ 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org