Invalid Plugin Exception

Discussion in 'Plugin Development' started by retsrif, Mar 3, 2011.

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

    retsrif

    After updating bukkit + craftbukkit, I'm getting an invalid plugin exception. The error:
    Code:
    [SEVERE] Could not load plugins\Refreshment.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:80)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:129)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:94)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:59)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:204)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:191)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:131)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:246)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.reflect.InvocationTargetException
        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:76)
        ... 8 more
    Caused by: java.lang.NullPointerException
        at retsrif.Refreshment.RBlockListener.<init>(RBlockListener.java:14)
        at retsrif.Refreshment.Refreshment.<init>(Refreshment.java:14)
        ... 13 more
    
    Any help?
     
  2. Offline

    Sammy

    Can you show me your code ?
    My guess is that you made an error on the yml file or on your plugins extended class
     
  3. Offline

    retsrif

    YML:
    Code:
    name: Refreshment
    main: retsrif.Refreshment.Refreshment
    version: 1.0
    Refreshment.java:
    Code:
    package retsrif.Refreshment;
    
    import java.io.File;
    
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Refreshment extends JavaPlugin {
        public static final Logger log = Logger.getLogger("Minecraft");
        private final RBlockListener blockListener = new RBlockListener(this);
        private final RPlayerListener playerListener = new RPlayerListener(this);
        public static Configuration Settings;
        public static String directory = "Refreshment" + File.separator;
    
        @Override
        public void onDisable() {
            log.log(Level.INFO, "[Refreshment] has been disabled.");
        }
    
        @Override
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
    
            setupDir();
    
            log.log(Level.INFO, "[Refreshment] has been enabled.");
        }
    
        public void setupDir() {
            (new File(directory)).mkdir();
            Settings = new Configuration(directory + "Refreshment.settings");
        }
    }
    --- merged: Mar 3, 2011 7:40 PM ---
    Still no one? I know I'm checking too early, though this thing has been bugging me!
     
  4. Offline

    xZise

    What do the two listeners in their constructors?

    Also use “this.getDataFolder()” to get the desired data directory. Then you don't spaming the bukkit root.

    Fabian
     
  5. Offline

    Sammy

    I'm not seeing any error, you have to show me the rest of your src code sorry [​IMG]

    "at retsrif.Refreshment.Refreshment.<init>(Refreshment.java:14)"
    That's the logger isn't it ? try taking it out... but I doubt it
     
  6. Offline

    xZise

    Argh the constructors of the listeners are irrelevant, because the stack trace don't touch them.

    My tip: Initialize the values in the “onEnable()”.

    Fabian
     
  7. Offline

    retsrif

    What values? I'll try removing the logger...
    --- merged: Mar 3, 2011 8:05 PM ---
    Nope, gives me the same error, and the exact same line... weird.
     
  8. Offline

    Sammy

    Code:
        public void setupDir() {
            (new File(directory)).mkdir();
            Settings = new Configuration(directory + "Refreshment.settings");
        }
    
    Make a if statement asking if the file exist before u make it, its housekeeping stuff, I don't think the error comes from it.

    Show us your listeners
     
  9. Offline

    retsrif

    Well I would rather not share the unique parts of it before I release it so I'll show you the standard parts:
    Code:
    public class RBlockListener extends BlockListener {
        public static Refreshment plugin;
    public RBlockListener(Refreshment instance) {
            plugin = instance;
        }
    }
    
    public class RPlayerListener extends PlayerListener {
        public static Refreshment plugin;;
    
        public RPlayerListener(Refreshment instance) {
            plugin = instance;
        }
    }
     
  10. Offline

    xZise

    For example
    Code:
    this.getDataFolder()
    . They got initialized after the constructor not in the constructor anymore.

    Fabian
     
  11. Offline

    Sammy

    Code:
     public static Refreshment plugin;;
    
    Two semiColons usually doesn't trow an error but still !
     
  12. Offline

    xZise

    Are you sure that you replaced/updated the jar?

    Fabian
     
  13. Offline

    Haerar

    Having the same problem with a plugin I've been working on. It was running just fine and dandy until the latest craftbukkit snapshot came out. My plugin and multiple others (not my own) have all started bringing up this error. Will download the new versions of the plugins in question, and see what they did to fix it (if they are indeed fixed at all...)
     
  14. Offline

    retsrif

    Has anyone figured out what the problem could be? I've looked at 5+ plugins now, all the same :(.
     
  15. Offline

    xZise

    What is your craftbukkit build so I could test this?

    Fabian
     
  16. Offline

    retsrif

    git-Bukkit-0.0.0-470-g8642b13-b453jinks
    --- merged: Mar 4, 2011 5:36 PM ---
    So any ideas? :(
    --- merged: Mar 4, 2011 7:25 PM ---
    How should I make my file then?
     
  17. Offline

    Dinnerbone Bukkit Team Member

    Code:
    Caused by: java.lang.NullPointerException
        at retsrif.Refreshment.RBlockListener.<init>(RBlockListener.java:14)
    Ok. Few things:

    1. Don't hardcode to that logger. Use getServer().getLogger().
    2. Set your values in onEnable.
    3. Your config directory should be getConfigDirectory() (or whatever the method is called). Don't make it yourself.
     
  18. Offline

    retsrif

    By the values, do you mean the listeners and the rest of the things? When I put them in onEnable(), it says illegal modifier only final is permitted.
     
  19. Offline

    Dinnerbone Bukkit Team Member

    Don't make them final, then.
     
  20. Offline

    xZise

    But nice tip with the logger. I should change this in my plugins.

    Fabian
    --- merged: Mar 4, 2011 9:35 PM ---
    Argh. I only now see, that the exception isn't in the main plugin. Could you please paste the complete file where the RBlockListener is defined? (The best would be if you paste them on pastebin.com)

    Fabian
     
  21. Offline

    retsrif

    Yes i found a problem in RBlockListener where it was asking for a specific thing from a file, but the file was never created in the first place, hence the null pointer exception.
     
Thread Status:
Not open for further replies.

Share This Page