Load jdbc driver with current classloader instead of system#261
Conversation
…ed. When running tests in SBT system classloader does not contain jdbc driver - SBT uses separate URLClassloader
|
@vkrot thanks for this - I'll do a little more reading to try and double check the implications of moving this to the current classloader. I'm perfectly OK with this in principle, though. |
|
According to http://www.kfu.com/~nsayer/Java/dyn-jdbc.html
But since we're about about the tests, it's not an issue, because we don't actually load it dynamically. So LGTM from me. |
|
@bsideup thanks - that's an interesting fact to note! This looks good to me too, so I'll merge. Side note: I think I may have done something similar in a fork when trying to (ab)use testcontainers to support this technique for jOOQ class generation. I remember there were some definite classloading tweaks required, but I'm afraid I don't have the details to hand. As I'd like to resurrect this Flyway-Testcontainers-jOOQ experiment one day soon I might have to tweak this again, but this time would do so aware of the needs of SBT. @vkrot if some time (no rush) you could point me at a minimal SBT+Testcontainers example repo, it would be useful to be able to refer back to for future regression testing. |
|
@rnorth , I'm really sorry for long delay, just forgot about this. Here is the minimal sbt project with testcontainers postgresql module - https://github.com/vkrot/testcontainers-sbt |
Load jdbc driver with current classloader instead of system classloader. When running tests in SBT system classloader does not contain jdbc driver - SBT uses separate URLClassloader.
Maybe there are some reasons to use system classloader instead of current one, that I'm not aware of? With this fix tests run well in SBT with scalatest.