From 035a43c37f5e015f682e6c110a6170709810bf63 Mon Sep 17 00:00:00 2001 From: vkrot Date: Wed, 11 Jan 2017 11:25:25 +0100 Subject: [PATCH] Load jdbc driver with current classloader instead of system classloaded. When running tests in SBT system classloader does not contain jdbc driver - SBT uses separate URLClassloader --- .../org/testcontainers/containers/JdbcDatabaseContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java index 1d972b72946..7d594cb1823 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java +++ b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java @@ -93,7 +93,7 @@ public Driver getJdbcDriverInstance() { synchronized (DRIVER_LOAD_MUTEX) { if (driver == null) { try { - driver = (Driver) ClassLoader.getSystemClassLoader().loadClass(this.getDriverClassName()).newInstance(); + driver = (Driver) Class.forName(this.getDriverClassName()).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new RuntimeException("Could not get Driver", e); }