I ran into a problem with the PostgreSQL JDBC driver running as an OSGi
bundle in karaf:
https://github.com/pgjdbc/pgjdbc/issues/1476
In short: the bundle works before restart, but after restart
DataSouce.getConnection() is unable to find the JDBC driver.
I've debugged through what happens, and the PGBundleActivator() seems to
do the right thing:
1. Call DriverManager.registerDriver() on bundle start
2. Call DriverManagerderegisterDriver() on bundle stop
3. Call DriverManager.registerDriver() again when the bundle restarts
(all of these in rt.jar)
However, after the second DriverManager.registerDriver() the
DriverManager.getConnection(String url, java.util.Properties info, Class<?> caller)
method fails because DriverManager.isDriverAllowed(Driver driver, ClassLoader classLoader)
fails (all of these in rt.jar).
And what fails in the isDriverAllowed() method is the comparison between
driver.getClass() and Class.forName(driver.getClass().getName()) fails.
Sounds like an OSGi classloader issue...?
How does the pax-jdbc bundles providing a DataSourceFactory handle JDBC
driver registration and unregistration?
Thanks!
- Steinar