Solved NoClassDefFoundError

Discussion in 'Plugin Development' started by Shiesh, Mar 7, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    Shiesh

    Hi,
    i'm currently working on a Plugin for 1.16.4 and ran into a quite unusual problem.
    At start the server is unable to load my plugin due to a NoClassDeffFoundError caused by the
    net.kyori.adventure.text package
    Code:
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/kyori/adventure/text/Component
       at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:139) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:383) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:185) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:808) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[server.jar:git-Spigot-37d799b-3eb7236]
       at java.lang.Thread.run(Thread.java:830) [?:?]
    
    After a google search I found that this Error is caused by the ClassLoader not finding the .class Files. However my IDE (Intellij) and Maven are telling me that the package is imported and in the classpath.

    I was able to track the source of this error down to these lines of code:
    Code:
    public static void sendLink(Player p, String message, String url){
         TextComponent component =Component.text(message);  
         component.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, url));
         p.sendMessage(component);
    }
    
    this is a utility method to send clickable texts to the player with a link to a webpage.

    I would appreciate any kind of help.
     
  2. Offline

    Kars

    Do you have any other plugins that use the same classname?
     
  3. Offline

    Shiesh

    No.
    But by using the net.md_5.bungee.api.chat library and the Player.spigot().sendMessage() method it works.
    However I still don't know what exactly caused the error.
     
  4. Offline

    poprundelhd

    I am having the same exact error... Components themselves were hard concepts for me because I am used to the old / deprecated methods, and now this
     
  5. Offline

    Kars

    Sounds like an ambiguous method to me.
     
Thread Status:
Not open for further replies.

Share This Page