Solved NoClassDefFoundError and ClassNotFoundException - Can't find CraftWorld class

Discussion in 'Plugin Development' started by PDKnight, Jul 30, 2015.

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

    PDKnight

    Hey there, I'm in big trouble now. I'm importing CraftWorld with this import:
    Code:java
    1. import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;

    but my server says it can't find that class. I'm using spigot 1.7.10-R0.1 (1649), but I don't know why it is not working :(
    I'm also using some other imports with cb v1_7_R3 and it seems spigot has got them, but this one specifically not.

    Error:
    Code:
    [21:59:03 ERROR]: Could not pass event WorldInitEvent to MoonGenerator v0.2.1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-1649]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1649]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [spigot.jar:git-Spigot-1649]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [spigot.jar:git-Spigot-1649]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.createWorld(CraftServer.java:1009) [spigot.jar:git-Spigot-1649]
            at org.bukkit.Bukkit.createWorld(Bukkit.java:250) [spigot.jar:git-Spigot-1649]
            at org.bukkit.WorldCreator.createWorld(WorldCreator.java:239) [spigot.jar:git-Spigot-1649]
            at com.onarandombox.MultiverseCore.utils.WorldManager.addWorld(WorldManager.java:137) [Multiverse-Core-2.4.jar:?]
            at com.onarandombox.MultiverseCore.commands.CreateCommand.runCommand(CreateCommand.java:94) [Multiverse-Core-2.4.jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.checkAndRunCommand(CommandHandler.java:279) [Multiverse-Core-2.4.jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.processFoundCommands(CommandHandler.java:143) [Multiverse-Core-2.4.jar:?]
            at com.pneumaticraft.commandhandler.multiverse.CommandHandler.locateAndRunCommand(CommandHandler.java:93) [Multiverse-Core-2.4.jar:?]
            at com.onarandombox.MultiverseCore.MultiverseCore.onCommand(MultiverseCore.java:476) [Multiverse-Core-2.4.jar:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) [spigot.jar:git-Spigot-1649]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [spigot.jar:git-Spigot-1649]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) [spigot.jar:git-Spigot-1649]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchServerCommand(CraftServer.java:753) [spigot.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.DedicatedServer.aB(DedicatedServer.java:326) [spigot.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:290) [spigot.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1649]
    Caused by: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_7_R3/CraftWorld
            at uk.co.jacekk.bukkit.almostflatlands.WorldListener.onWorldInit(WorldListener.java:25) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
            at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigot.jar:git-Spigot-1649]
            ... 21 more
    Caused by: java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_7_R3.CraftWorld
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:91) ~[spigot.jar:git-Spigot-1649]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-1649]
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_45]
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_45]
            at uk.co.jacekk.bukkit.almostflatlands.WorldListener.onWorldInit(WorldListener.java:25) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
            at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigot.jar:git-Spigot-1649]
            ... 21 more
    Please, I really need your help ;(
     
  2. Offline

    FisheyLP

    Make your plugin print out: Bukkit.getServer().getClass().getPackage().getName() to see the version of the server
     
  3. Offline

    PDKnight

    @FisheyLP
    org.bukkit.craftbukkit.v1_7_R4

    EDIT: I'm sorry. How to import the latest version then (I mean as the Referenced libs in Eclipse)?
     
  4. Offline

    FisheyLP

    When using nms/cb code you need to import the same craftbukkit.jar as your server or the error you had will happen.
    Anyways: Rightclick on your project -> Build path -> Configure Built Path.. -> *click on the current craftbukkit* -> Edit.. -> *select correct craftbukkit -> Open -> OK.

    Maybe you need to refresh your project after that
     
  5. Offline

    teej107

    @PDKnight Do you even need to import CraftWorld? Why can't you use Bukkit's World?
     
  6. Offline

    PDKnight

    @FisheyLP I used spigot.jar, thanks anyway!

    @teej107 I have to import it, because of this line:
    Code:java
    1. final WorldServer worldServer = ((CraftWorld)world).getHandle();
     
  7. Offline

    teej107

    Ok. If you aren't using NMS then you shouldn't import their classes.
     
  8. Offline

    PDKnight

Thread Status:
Not open for further replies.

Share This Page