InvalidPluginException error [Resolved]

Discussion in 'Plugin Development' started by Choltfo, Apr 26, 2012.

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

    Choltfo

    I am starting a Bukkit plugin. So far, all it is supposed to do is write some text to the console when the server starts and closes. However, it has never gotten to that point, and i receive the following error(s?) on running the server
    Code:
    22:35:23 [SEVERE] Could not load 'plugins\attempt.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:148)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:53)
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    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 com.gmail.maxride34.attempt.attempt.<init>(attempt.java:6)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
     
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:144)
            ... 8 more
    as for source code, Here is "Plugin.yml" and "attempt.java"

    Code:
    name: attempt
    main: com.gmail.maxride34.attempt.attempt
    version: 1.1.1
    and attempt.java
    Code:
    package com.gmail.maxride34.attempt;
    package com.gmail.maxride34.attempt;
    import java.util.logging.Logger;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class attempt extends JavaPlugin {
    Logger log = this.getLogger();
    public void onEnable(){
    log = this.getLogger();
    log.info("Your plugin has been enabled!");
    }
    public void onDisable(){
    log = this.getLogger();
    log.info("Thank you for using this plugin. Made by Choltfo and Xelerayte");
    }
    }
    
    Attempt.png
    The plugin.yml is in the root of the project (outside of src) and the main class is inside a package (com.gmail.maxride34.attempt) inside src.
    Any help would be greatly appreciated, as I cannot for the life of me figure this out.
    Thanks in advance
     
  2. Offline

    r0306

    Personally, I hate using Logger, but that's just me. If you use this code, I guarantee that it will work 99% of the time, unless there's something wrong with your build path.
    Code:
    package com.gmail.maxride34.attempt;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class attempt extends JavaPlugin {
    public void onEnable(){
    System.out.println("Your plugin has been enabled!");
    }
    public void onDisable(){
    System.out.println("Thank you for using this plugin. Made by Choltfo and Xelerayte");
    }
    }
     
  3. Offline

    Choltfo

    THANK YOU!!! it worked! I had been avoiding this method after a friend of mine suggested that using println instead of logger would not work.
    I will inform him of his incorrect statement.
    Thanks
     
  4. Offline

    Blairjam

    You shouldn't use println(), it only prints out to the server, while the logger will write into the server log as well as print it on screen. To use it, you need to give a argument of "Minecraft".
    Code:
    package com.gmail.maxride34.attempt;
    package com.gmail.maxride34.attempt;
    import java.util.logging.Logger;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class attempt extends JavaPlugin {
    Logger log = this.getLogger("Minecraft"); //<---------
    public void onEnable(){
    log = this.getLogger();
    log.info("Your plugin has been enabled!"); //You don't need this.
    }
    public void onDisable(){
    log = this.getLogger();
    log.info("Thank you for using this plugin. Made by Choltfo and Xelerayte");
    }
    }
    
    Edit: Bukkit will now automatically print out when plugins are enabled and disabled, meaning that you don't have to tell when a plugin starts. You can still use the above logging method to give yourself credit in the onDisable though.
     
  5. Offline

    Choltfo

    Thank's for the advice, however, println does print to the log.
     
  6. Offline

    Blairjam

    :p ok then I don't know why I use logger, somewhere along the way I heard that it was better to use XD
     
Thread Status:
Not open for further replies.

Share This Page