nikosgram / gringotts

Gringotts is an item-based economy plugin for the Bukkit Minecraft server platform. Unlike earlier economy plugins, all currency value and money transactions are based on actual items in Minecraft, per default emeralds.
https://www.spigotmc.org/resources/gringotts.42071/
BSD 2-Clause "Simplified" License
42 stars 35 forks source link

Paper Server 1.17.1: Incompatibility of CoreProtect 20.1/20.3 with Gringotts 2.12.2 #82

Closed silen72 closed 1 year ago

silen72 commented 2 years ago

Describe the bug

I have a server (Paper, MC:1.16.5) with quite a few plugins. CoreProtect (19.5) is configured to use a MySQL database (version 8.0.22). One of the other plugins is Gringotts v2.12.2. This works well.

Currently I'm trying to upgrade my server to Paper, MC:1.17.1 (git-Paper-399). For this, I have also upgraded CoreProtect (to 20.1) - Gringotts is already the current version. I have also switched to Java 17 (OpenJDK 64-Bit Server VM 17.0.1+12-39). With this configuration, CoreProtect fails to connect to the database:

[20:52:55 INFO]: [CoreProtect] Unable to connect to MySQL server. [20:52:55 WARN]: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/minecraft?useUnicode=true&characterEncoding=utf-8&connectTimeout=10000&useSSL=false&allowPublicKeyRetrieval=true&useCursorFetch=true&useLocalSessionState=true&rewriteBatchedStatements=true&maintainTimeStats=false [20:52:55 WARN]: at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706) [20:52:55 WARN]: at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) [20:52:55 WARN]: at CoreProtect-20.1.jar//net.coreprotect.database.Database.getConnection(Database.java:143) [20:52:55 WARN]: at CoreProtect-20.1.jar//net.coreprotect.database.Database.createDatabaseTables(Database.java:320) [20:52:55 WARN]: at CoreProtect-20.1.jar//net.coreprotect.config.ConfigHandler.loadDatabase(ConfigHandler.java:205) [20:52:55 WARN]: at CoreProtect-20.1.jar//net.coreprotect.config.ConfigHandler.performInitialization(ConfigHandler.java:367) [20:52:55 WARN]: at CoreProtect-20.1.jar//net.coreprotect.CoreProtect.onEnable(CoreProtect.java:71) [20:52:55 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [20:52:55 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) [20:52:55 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) [20:52:55 WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) [20:52:55 WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) [20:52:55 WARN]: at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) [20:52:55 WARN]: at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:317) [20:52:55 WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1220) [20:52:55 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) [20:52:55 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)

For troubleshooting I have disabled all plugins but CoreProtect. After a restart, CoreProtect was back to normal; it successfully connected to my MySQL server. I have then reenabled one plugin after another. What I found out is, that as soon as I have Gringotts and CoreProtect both active, CoreProtect fails to connect.

I do not know if this is rather an issue with CoreProtect or with Gringotts, so I decided to file an issue with both plugins.

To Reproduce

Steps to reproduce the behavior:

Expected behavior

Activating the Gringotts plugin does not interfere with CoreProtect. CoreProtect can still access its configured MySQL server when Gringotts is also activated.

Screenshots

No screenshots, it's all in the servers log.

Desktop (please complete the following information):

Additional context

Also filed this as an issue with CoreProtect, see https://github.com/PlayPro/CoreProtect/issues/117

Maybe this is valuable info: when shutting down the server, there are warnings caused by gingotts that also seem database related:

[20:55:45 INFO]: Closing Server [20:55:52 WARN]: java.lang.IllegalStateException: zip file closed [20:55:52 WARN]: at java.base/java.util.zip.ZipFile.ensureOpen(ZipFile.java:831) [20:55:52 WARN]: at java.base/java.util.zip.ZipFile.getEntry(ZipFile.java:330) [20:55:52 WARN]: at java.base/java.util.jar.JarFile.getEntry(JarFile.java:518) [20:55:52 WARN]: at java.base/java.util.jar.JarFile.getJarEntry(JarFile.java:473) [20:55:52 WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:163) [20:55:52 WARN]: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587) [20:55:52 WARN]: at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:108) [20:55:52 WARN]: at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) [20:55:52 WARN]: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) [20:55:52 WARN]: at gringotts-2.12.2.jar//com.avaje.ebeaninternal.server.lib.sql.PooledConnectionQueue.createStatus(PooledConnectionQueue.java:125) [20:55:52 WARN]: at gringotts-2.12.2.jar//com.avaje.ebeaninternal.server.lib.sql.PooledConnectionQueue.shutdown(PooledConnectionQueue.java:354) [20:55:52 WARN]: at gringotts-2.12.2.jar//com.avaje.ebeaninternal.server.lib.sql.DataSourcePool.shutdown(DataSourcePool.java:689) [20:55:52 WARN]: at gringotts-2.12.2.jar//com.avaje.ebeaninternal.server.lib.sql.DataSourceManager.shutdown(DataSourceManager.java:170)

silen72 commented 2 years ago

Upon closer inspection on the server log I have noticed more entries that might be of interest. These entries originate from Gringotts - without Gringotts they are gone.

System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.1+12-39) Host: Windows 10 10.0 (amd64) Loading libraries, please wait... [18:41:53 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD' [18:41:54 INFO]: Reloading ResourceManager: Default, bukkit [18:41:55 INFO]: Loaded 7 recipes [18:41:56 INFO]: Starting minecraft server version 1.17.1 [18:41:56 INFO]: Loading properties [18:41:56 INFO]: This server is running Paper version git-Paper-399 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: d4318a6 on ver/1.17.1) [18:41:56 INFO]: Server Ping Player Sample Count: 12 [18:41:56 INFO]: Using 4 threads for Netty based IO [18:41:56 INFO]: Default game type: SURVIVAL [18:41:56 INFO]: Generating keypair [18:41:56 INFO]: Starting Minecraft server on *:25565 [18:41:56 INFO]: Using default channel type [18:41:56 INFO]: Paper: Using Java 11 compression from Velocity. [18:41:56 INFO]: Paper: Using Java cipher from Velocity. [18:41:57 ERROR]: [com.avaje.ebean.config.PropertyMapLoader] ebean.properties not found [18:41:57 INFO]: [com.avaje.ebeaninternal.server.lib.sql.DataSourcePool] DataSourcePool [Gringotts] autoCommit[false] transIsolation[SERIALIZABLE] min[2] max[20] [18:41:57 INFO]: [com.avaje.ebeaninternal.server.subclass.SubClassManager] SubClassFactory parent ClassLoader [org.bukkit.plugin.java.PluginClassLoader] [18:41:57 INFO]: [com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager] Entities enhanced[0] subclassed[2] [18:41:57 INFO]: [CoreProtect] Loading CoreProtect v20.1 [18:41:57 INFO]: [Gringotts] Loading Gringotts v2.12.2

silen72 commented 2 years ago

Please also consider what Intelli said over at CoreProtect

My own plugin (that uses jdbc natively - without fancy ORM ;-) has the same problem: It simply fails to connect to the MySQL/MariaDB database whenever I activate Gringotts in parallel -> Intelli seems to have a point there...

silen72 commented 2 years ago

So... In the meantime CoreProtect has switched to HikariCP. The problem still exists but the log differs. Here is:

[21:44:47] [Server thread/INFO]: [CoreProtect] Enabling CoreProtect v20.3 [21:44:47] [Server thread/INFO]: [net.coreprotect.hikari.HikariDataSource] HikariPool-1 - Starting... [21:44:47] [Server thread/WARN]: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:mysql://localhost:3306/minecraft [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.util.DriverDataSource.(DriverDataSource.java:114) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:331) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.pool.PoolBase.(PoolBase.java:114) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.pool.HikariPool.(HikariPool.java:108) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.HikariDataSource.(HikariDataSource.java:81) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.config.ConfigHandler.loadDatabase(ConfigHandler.java:232) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.config.ConfigHandler.performInitialization(ConfigHandler.java:398) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.CoreProtect.onEnable(CoreProtect.java:71) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) [21:44:47] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:317) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1220) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) [21:44:47] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833) [21:44:47] [Server thread/WARN]: Caused by: java.sql.SQLException: No suitable driver [21:44:47] [Server thread/WARN]: at java.sql/java.sql.DriverManager.getDriver(DriverManager.java:299) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.hikari.util.DriverDataSource.(DriverDataSource.java:106) [21:44:47] [Server thread/WARN]: ... 17 more [21:44:47] [Server thread/INFO]: [CoreProtect] Unable to connect to MySQL server. [21:44:47] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "net.coreprotect.hikari.HikariDataSource.getConnection()" because "net.coreprotect.config.ConfigHandler.hikariDataSource" is null [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.database.Database.getConnection(Database.java:141) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.database.Database.getConnection(Database.java:130) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.config.ConfigHandler.performInitialization(ConfigHandler.java:405) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.CoreProtect.onEnable(CoreProtect.java:71) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) [21:44:47] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:317) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1220) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) [21:44:47] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833) [21:44:47] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "java.sql.Connection.createStatement()" because "connection" is null [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.config.ConfigHandler.performInitialization(ConfigHandler.java:406) [21:44:47] [Server thread/WARN]: at CoreProtect-20.3.jar//net.coreprotect.CoreProtect.onEnable(CoreProtect.java:71) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) [21:44:47] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) [21:44:47] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) [21:44:47] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:317) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1220) [21:44:47] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) [21:44:47] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833)

silen72 commented 2 years ago

Could it be an incompatibility between the outdated(?) version 2.8.1 of ebean you are using and Java 17? As far as I can see the current version of ebean is 12.12.1 ... I wasn't able to compile your code after a simple upgrade of ebean. The API is too different to simply compile and my ORM skills are way too limited to adapt your code to the changes :-/

silen72 commented 2 years ago

please see #https://github.com/PlayPro/CoreProtect/issues/117#issuecomment-1002599682

MCMDEV commented 2 years ago

Same issue here with Prism.

MCMDEV commented 2 years ago

I can also verify that updating to Ebean 12.12.1 does NOT fix the issue, sadly. I did it and it didn't fix anything. From my current findings, the Ebean dependency somehow stops the DriverManager from finding an appropriate driver for a connection url. In Prism, I can just manually define the name of the driver. I'm going to open up a pull request that gets rid of Ebean entirely soon.

silen72 commented 2 years ago

Thank you very much for confirming the issue and for testing it with the current Ebean version, @MCMDEV!

Looking forward to the pull request you mentioned.