I am getting a NoClassDefFoundError exception I don't know Why because my class is imported and there are no errors in the compiler but when I run the plugin the error is. I even checked if the .class file exists in the .jar file and it existed so I don't know what the problem is here is the exception I got:
[22:45:24] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'sb' in plugin YTScoreboard v2.6.3
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:761) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:1936) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1779) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1732) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:28) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(SourceFile:144) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(SourceFile:118) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1061) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1054) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(SourceFile:103) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1037) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:970) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class pl.Werokowy.ytscoreboard.ScoreboadAPI
at pl.Werokowy.ytscoreboard.SBCmd.onCommand(SBCmd.java:57) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[1.16.jar:3096a-Spigot-9fb885e-af1a232]
... 19 more
The code is very simple so I rather not need to show it: ScoreboardAPI.updateScoreboard()
CodePudding user response:
If the classes do not create problems during compilation and the jar file is build from that I assume both classes are part of the same jar and thus the classpath is not the issue.
See the text in your NoClassDefFoundError: Could not initialize class pl.Werokowy.ytscoreboard.ScoreboadAPI
This is not a "ClassNotFoundException", and it points towards a problem while constructing the class or the instance. Maybe it is not the constructor throwing an exception, but it could also be code that needs to run besides the constructor or even on class level.
Check your variable definitions (and how they get initialized), and also check for static initializers.