Solved ClassNotFoundException and noClassDefError

Discussion in 'Spigot Plugin Help' started by Stexjy, Mar 21, 2020.

  1. Hello, today I was trying to make a plugin using apis from Heroes plugin but I got this error:

    Code (Text):
    [19:00:48 ERROR]: Could not load 'plugins\SkillsProva.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/herocraftonline/heroes/characters/skill/Skill
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:291) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.reload(CraftServer.java:744) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.Bukkit.reload(Bukkit.java:534) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchServerCommand(CraftServer.java:632) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.DedicatedServer.aM(DedicatedServer.java:353) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:317) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
    Caused by: java.lang.NoClassDefFoundError: com/herocraftonline/heroes/characters/skill/Skill
            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.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            ... 14 more
    Caused by: java.lang.ClassNotFoundException: com.herocraftonline.heroes.characters.skill.Skill
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_241]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            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.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            ... 14 more
    Plugin:

    Code (Text):
    package provaheroes.main;

    import org.bukkit.Bukkit;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import com.herocraftonline.heroes.Heroes;
    import com.herocraftonline.heroes.characters.Hero;
    import com.herocraftonline.heroes.characters.skill.Skill;
    import com.herocraftonline.heroes.characters.skill.SkillManager;

    public class ProvaHeroes extends JavaPlugin implements Listener{
       
        static Skill skill = null;
       
        public void onEnable() {
           
            try {
                config();
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           
            PluginManager pm = Bukkit.getPluginManager();
           
            pm.registerEvents(this, this);
           
        }
       
        public void onDisable() {
           
           
           
        }
       
        public static void config() throws ClassNotFoundException {
           
            try {
               
                skill = new Skill(Heroes.getPlugin(Heroes.class), "SkillProva") {
                   
                    public void init() {
                       
                       
                       
                    }
                   
                    public String getDescription(Hero arg0) {
                       
                        return skill.getDescription();
                       
                    }
                   
                    public boolean execute(CommandSender cs, String s, String[] args) {
                       
                        return false;
                       
                    }
                   
                };
               
            }catch(NoClassDefFoundError exc) {
               
               
               
            }
           
            Bukkit.getConsoleSender().sendMessage(skill.getDescription());
           
            SkillManager sm = new SkillManager(Heroes.getPlugin(Heroes.class));
           
            skill.setDescription("prova");
           
            sm.addSkill(skill);
           
            Bukkit.getConsoleSender().sendMessage(sm.getSkill("SkillProva").getDescription());
           
        }
       
        @EventHandler
        public void onChat(PlayerChatEvent e) {
           
            try {
                config();
            } catch (ClassNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
           
            Player p = e.getPlayer();
           
            p.sendMessage("description: " + skill.getDescription());
           
        }
       
    }
     
  2. Is Heroes plugin installed?
     
  3. I mean, on server. Does plugin really work? Is it specified in your plugin.yml as a dependency?
     
  4. what do I need to put in my plugin.yml??
     
  5. wait maybe I found a problem cause
     
  6. still now working
     
  7. ok added the depend thing, now I get another error lol, let me see if I can fix it
     
  8. it works fine, THANK YOU VERY MUCH!!
     
  9. how to put [Solved]??
     
  10. Thread Tools > Edit Title > Select "Solved" tag
     
  11. Thank you dude!!