Reputation:
Can someone please help me out.
I am getting a NoClassDeffFound error and I do not know why.
I am trying to code minecraft plugin for a friends guild and I am getting an error when trying to get info about the player.
I am using this api wrapper: https://github.com/KevinPriv/HypixelApi4J
This is my build.gradle:
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://jitpack.io' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT'
compile "com.github.KevinPriv:HypixelApi4J:API-1.7"
}
and this is my main class:
public void onEnable(){ HypixelAPI hypixel = new HypixelAPI(KEY); String id = ""; try { id = hypixel.getGuildID("Miqhtie"); } catch (IOException e) { e.printStackTrace(); } catch (APIException e) { e.printStackTrace(); } Guild guild = null; try { guild = hypixel.getGuild(id); } catch (IOException e) { e.printStackTrace(); } catch (APIException e) { e.printStackTrace(); } System.out.println("Guild Name: " + guild.getName()); } }
and here is my stack trace:
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: me/kbrewster/exceptions/APIException at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:139) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.craftbukkit.v1_16_R1.CraftServer.loadPlugins(CraftServer.java:377) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.DedicatedServer.init(DedicatedServer.java:186) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:808) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at java.lang.Thread.run(Unknown Source) [?:1.8.0_241] Caused by: java.lang.NoClassDefFoundError: me/kbrewster/exceptions/APIException at java.lang.Class.forName0(Native Method) ~[?:1.8.0_241] at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_241] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] ... 7 more Caused by: java.lang.ClassNotFoundException: me.kbrewster.exceptions.APIException at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_241] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:167) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:96) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_241] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_241] at java.lang.Class.forName0(Native Method) ~[?:1.8.0_241] at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_241] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.16.1.jar:git-Spigot-758abbe-2b00831] ... 7 more```
Upvotes: 2
Views: 543
Reputation: 405
You need to shade the dependency into your jar with the Gradle Shadow Plugin.
Upvotes: 0