Skip to content
Browse files
Use correct ClassLoader for loading default app config
A custom ClassLoader (or Slick’s own default ClassLoader) was used for
resolving driver or connection pool classes but not for the default
application config (via Typesafe Config). This relied on Typesafe
Config’s own default ClassLoder which does not work properly from a
macro when compiling in sbt.
  • Loading branch information
szeiger committed Mar 23, 2017
1 parent 1ad8272 commit 7922989cfc19f7c73ce0a1b170f0de536fa0af97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
@@ -124,7 +124,7 @@ object DatabaseConfig {
else (s.substring(0, s.length-f.length-1), uri.getFragment)
val root =
if(base eq null) ConfigFactory.load()
if(base eq null) ConfigFactory.load(classLoader)
else ConfigFactory.parseURL(new URL(base)).resolve()
forConfig[P](path, root, classLoader)
@@ -282,9 +282,10 @@ trait JdbcBackend extends RelationalBackend {
* @param classLoader The ClassLoader to use to load any custom classes from. The default is to
* try the context ClassLoader first and fall back to Slick's ClassLoader.
def forConfig(path: String, config: Config = ConfigFactory.load(), driver: Driver = null,
def forConfig(path: String, config: Config = null, driver: Driver = null,
classLoader: ClassLoader = ClassLoaderUtil.defaultClassLoader): Database = {
val usedConfig = if(path.isEmpty) config else config.getConfig(path)
val initializedConfig = if(config eq null) ConfigFactory.load(classLoader) else config
val usedConfig = if(path.isEmpty) initializedConfig else initializedConfig.getConfig(path)
val source = JdbcDataSource.forConfig(usedConfig, driver, path, classLoader)
val poolName = usedConfig.getStringOr("poolName", path)
val numThreads = usedConfig.getIntOr("numThreads", 20)

0 comments on commit 7922989

Please sign in to comment.