Error?

Discussion in 'Plugin Development' started by xXm0difierXx, Mar 8, 2012.

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

    xXm0difierXx

    I never made a plugin before and i'm trying to make a test plugin but i get a error when i start the server.

    Code:
    Basic.java
    Code:
    package America.xXm0difierXx.Basic;
     
    import java.util.logging.Logger;
    import org.bukkit.plugin.java.JavaPlugin;
     
    /**
    * Basic for Bukkit
    *
    * @author xXm0dzxx
    *
    */
     
    public class Basic extends JavaPlugin {
     
        Logger log = this.getLogger();
       
        public void onEnable() {
            log.info("test");
        }
       
        public void onDisable() {
            log.info("test failed");
        }
    }
    
    plugin.yml
    Code:
    name: Basic
    main: America.xXm0difierXx.Basic
    version: 1.0.1
    Error:
    Code:
    2012-03-08 18:03:26 [SEVERE] Could not load 'plugins\Basic.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: America.xXm0difierXx.Basic
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:150)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:287)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:211)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:206)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:182)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:147)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:407)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    Caused by: java.lang.ClassNotFoundException: America.xXm0difierXx.Basic
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:139)
        ... 8 more
     
  2. Offline

    billofbong

    This just looks like you haven't included Basic in the jar. Add it in, and it should work just fine.
     
  3. Offline

    xXm0difierXx

    Its in there
     
  4. Offline

    billofbong

    ClassNotFoundException means it well... Can't find the class. Is your jar in a structure like yourjar.jar/America/xXm0difierXx/Basic.class?
     
  5. Offline

    xXm0difierXx

    Yea

    Heres what the file looks like:
    Code:
    Basic.jar
      META-INF
        MANIFEST.MF
     
      America
        xXm0difierXx
          Basic
            Basic.class
     
      plugin.yml
     
  6. Offline

    Adrenaline

    Plugin.yml - try this
    PHP:
    nameBasic
    main
    America.xXm0difierXx.Basic.Basic
    version
    1.0.1
     
  7. Offline

    xXm0difierXx

    Code:
    2012-03-08 20:03:12 [SEVERE] Could not load 'plugins\Basic.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:148)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:287)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:211)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:206)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:182)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:147)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:407)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    Caused by: java.lang.NullPointerException
        at org.bukkit.plugin.PluginLogger.<init>(PluginLogger.java:22)
        at org.bukkit.plugin.java.JavaPlugin.getLogger(JavaPlugin.java:359)
        at America.xXm0difierXx.Basic.Basic.<init>(Basic.java:15)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
        ... 8 more
     
  8. Offline

    Adrenaline

    Change at Basic.java
    Logger log = this.getLogger();

    to

    Logger log = Logger.getLogger("Minecraft");
     
  9. Offline

    xXm0difierXx

    Thanks it works!
     
  10. Offline

    Adrenaline

  11. Offline

    Lolmewn Retired Staff

    OR do this:

    Code:
    Logger log;
     
    public void onEnable(){
        log = this.getLogger();
    }
     
Thread Status:
Not open for further replies.

Share This Page