question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't load implementation for DatabaseConnectionAutoRegistration

See original GitHub issue
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)
        })
    )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
Tapaccommented, Dec 30, 2019

You have to add exposed-jdbc into your dependency. It’s a transport layer implementation (the only at the moment).

8reactions
StepBySteplercommented, Dec 30, 2019

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 with Thread.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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ServiceLoader doesn't load implementation - Stack Overflow
I keep getting a NoSuchElementException at the iterator part which means that the implementation was not loaded. Thanks in advance.
Read more >
Erik Pragt on Twitter: "I've tried giving #DuckDuck, #Qwant, #Bing a ...
... you can't even match an exact title on a GitHub issue :-( (FYI, my search query was: Can't load implementation for DatabaseConnectionAutoRegistration)" ......
Read more >
IqrvpctbzN | SourceBin
[12:55:48 ERROR]: Could not load 'plugins\eco-6.32.0-all.jar' in folder 'plugins'. org.bukkit.plugin.InvalidPluginException: java.lang.
Read more >
Hi Issue 748 is blocking me from upgrading to the 0 20 x ser ...
IllegalStateException : Can't load implementation for DatabaseConnectionAutoRegistration . If I roll back to 0.17.7 (and make the changes to dependencies and ...
Read more >
Issue with relocation using Shadow Jar - JetBrains/Exposed
IllegalStateException : Can't load implementation for DatabaseConnectionAutoRegistration at com.github.secretx33.dependencies.gtblocks.exposed.sql.Database.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found