Exposed: Can't load implementation for DatabaseConnectionAutoRegistration
java.lang.ExceptionInInitializerError: null
at one.xjcyan1de.creativeplus.CreativePlus.connectDatabase(CreativePlus.kt:70) ~[?:?]
at one.xjcyan1de.creativeplus.CreativePlus.enable(CreativePlus.kt:43) ~[?:?]
at com.github.xjcyan1de.cyanlibz.plugin.ExtendedBukkitPlugin.onEnable(ExtendedBukkitPlugin.kt:38) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.15.1.jar:git-Paper-27]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:338) ~[patched_1.15.1.jar:git-Paper-27]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:420) ~[patched_1.15.1.jar:git-Paper-27]
at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:468) ~[patched_1.15.1.jar:git-Paper-27]
at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:382) ~[patched_1.15.1.jar:git-Paper-27]
at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:481) ~[patched_1.15.1.jar:git-Paper-27]
at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:290) ~[patched_1.15.1.jar:git-Paper-27]
at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:884) ~[patched_1.15.1.jar:git-Paper-27]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.IllegalStateException: Can't load implementation for DatabaseConnectionAutoRegistration
at org.jetbrains.exposed.sql.Database.<clinit>(Database.kt:64) ~[?:?]
... 12 more
CreativePlus.connectDatabase:
private fun connectDatabase() = Database.connect(
HikariDataSource(HikariConfig().apply {
jdbcUrl = Config.sqlUrl
driverClassName = Config.sqlDriver
username = Config.sqlUsername
password = Config.sqlPassword
maximumPoolSize = 4
addDataSourceProperty("cachePrepStmts", "true")
addDataSourceProperty("prepStmtCacheSize", "250")
addDataSourceProperty("prepStmtCacheSqlLimit", "2048")
addDataSourceProperty("characterEncoding", "utf8")
addDataSourceProperty("useUnicode", "true")
addDataSourceProperty("useSSL", "false")
addDataSourceProperty("useJDBCCompliantTimezoneShift", "true")
addDataSourceProperty("useLegacyDatetimeCode", "false")
addDataSourceProperty("serverTimezone", TimeZone.getDefault().id)
})
)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Can't load implementation for DatabaseConnectionAutoRegistration #748 — committed to JetBrains/Exposed by Tapac 4 years ago
You have to add
exposed-jdbc
into your dependency. It’s a transport layer implementation (the only at the moment).Encountered the same issue. The problem is that exposed classes here are loaded by other ClassLoader instance, but line 64 of org.jetbrains.exposed.sql.Database uses contextClassLoader under the hood:
ServiceLoader.load(DatabaseConnectionAutoRegistration::class.java)
invokes overload withThread.currentThread().getContextClassLoader()
. I suggest to manually specify the classloader to search (org.jetbrains.exposed.sql.Database::class.java.classLoader
, for example). This way dynamically loaded jars (like Bukkit plugins) can also use Exposed.It’s still in version 0.28.1
Still having this issue?
I’m on 0.28.1, and the advice to include exposed-jdbc worked for me.
So if i use @StepByStepler suggestion its loads exposed-jdbc connection impl. but exposed still use context service loader.