Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-04-30 Thread Steinar Bang
> Christian Schneider 
> :

> I see no calls to DriverManager in
> https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java

The DriverManager isn't called directly from the PGBundleActivator.

 1. DriverManager.registerDriver() is called from Driver.register()
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L720
 2. Driver.register() is called from a static initializer in the Driver class
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L72
 3. DriverManager.deregisterDriver() is called from Driver.deregister()
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L737
 4. Driver.deregister() is called from the PGBundleActivator.stop() method
 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java#L56

> It only registers and unregisters the DataSourceFactory service which looks
> correct.

Yes, that bit is correct, and populates to my DS components that has
@Reference to DatasourceFactory (the old service is unbound and the
activate methods are called using the new service).

> Not sure about the call to Driver.deregister though.
> This might cause the issue.

See comment in the issue
 https://github.com/pgjdbc/pgjdbc/issues/1476#issuecomment-487370634

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-04-30 Thread Christian Schneider
I see no calls to DriverManager in
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java

It only registers and unregisters the DataSourceFactory service which looks
correct.
Not sure about the call to Driver.deregister though.
This might cause the issue.

Christian


Am Mo., 29. Apr. 2019 um 18:58 Uhr schrieb Steinar Bang :

> 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
>
> --
> --
> --
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.