Can't find dependency when plugin is run in server (NoClassDefFoundError)
Closed this issue · 1 comments
I've tried for a few hours to get a plugin to run with multiple versions of this api. I want to use it so badly because it looks so cool and simple, but I can't get past this part. I've even tried bundling it with my jar. I've tried multiple versions of minecraft and multiple versions of Paper. No luck. I can see the dependency in Intellij, code completion happens and I can even ctrl+click into the classes. But when I build the plugin and deploy it to the server, I get the error below:
java.lang.NoClassDefFoundError: me/catcoder/sidebar/ProtocolSidebar
at org.braekpo1nt.mctmanager.games.footrace.FootRaceGame.<init>(FootRaceGame.java:67) ~[MCTManager-0.1.0-0.jar:?]
at org.braekpo1nt.mctmanager.games.GameManager.<init>(GameManager.java:43) ~[MCTManager-0.1.0-0.jar:?]
at org.braekpo1nt.mctmanager.Main.onEnable(Main.java:47) ~[MCTManager-0.1.0-0.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:371) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:544) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.enablePlugin(CraftServer.java:578) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.enablePlugins(CraftServer.java:492) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.reload(CraftServer.java:1038) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.Bukkit.reload(Bukkit.java:930) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.dispatchCommand(CraftServer.java:929) ~[paper-1.19.3.jar:git-Paper-384]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.dispatchServerCommand(CraftServer.java:892) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:494) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:441) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-384]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-384]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: me.catcoder.sidebar.ProtocolSidebar
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:177) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:124) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 20 more
Please follow the example from the test plugin available at https://github.com/CatCoderr/ProtocolSidebar/tree/1350cc27e4616eb6c4170d587410b1e8884f0ccc/test-plugin.
This plugin has been tested on Paper 1.19.3 with the latest ProtocolLib and works perfectly. Additionally, if you used Intellij's build system to create your JARs, I recommend considering using Maven or Gradle instead.