|Re: Problem with JDBC driver not being found after bundle refresh [message #660388 is a reply to message #659957]
||Fri, 18 March 2011 09:32
|| Sven Panko
Registered: February 2011
Further investigation revealed that the problem is related to the postgresql JDBC driver bundle(I osgified the plain JDBC jar using Bundlor and used it successfully in other scenarios).|
While debugging I detected that - due to an unknown reason - the DriverManager's internal registered JDBC driver list changed. Debugging this class is difficult due to the fact that everything in it is static (another reason why I think static does not belong in an OO language, but that's another point ). Anyway, I detected that upon the first start of my bundle the internal driver list contains exactly one JDBC driver, namely my postgres driver. On all subsequent starts the list did not contain it, but it wasn't even the same list (memory-wise) than the first list. However, the list of all subsequent starts remained the same, so only the first time the bundle is started I get a different one. This can only happen in two cases:
* a Driver explicitly deregisters itself from the DriverManager (which the postgres driver doesn't)
* somehow a second DriverManager class is loaded by a different classloader *after* the Postgres JDBC driver has been loaded into memory by a classloader (postgres' driver performs registration upon loading of the class by the classloader)
Although I don't have any definite proof it seems that upon the first start of the bundle I get a different DriverManager than on subsequent starts. Then I performed a little trick: after the initial (successful) start of my bundle I explicitly refreshed the postgres bundle in the container and voila, *all* subsequent redeployments succeeded from there on.
I have a very vague suspicion but no evidence to prove it: is it possible that the first bundle start (and likewise the postgres driver that is started during bundle resolution phase) gets access to the DriverManager class that is loaded by the kernel-region Equinox, while at all subsequent starts the user-region Equinox provides the DriverManager class? I am not entirely sure my suspicion is justified because I only observed that the Equinox runtime is started two times (I detected it when I saw that my osgi.debug options only affected the kernel bundles and afterwards no additional output was printed, until I eventually also modified the org.eclipse.virgo.kernel.userregion.properties file and added additional debug options there), but I don't know if there is any relation.
Anyhow, I have a workaround for now (just refresh the postgres bundle once before performing any redeployments) and that does the trick for me.
[Updated on: Fri, 18 March 2011 09:49]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02691 seconds