Solved PluginAlreadyInitialized Exception

Discussion in 'Plugin Development' started by Davesan, Jan 3, 2014.

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

    Davesan

    [SOLUTION]

    [ORIGINAL POST]​
    Hello guys! I always get
    Code:java
    1. java.lang.IllegalArgumentException: Plugin already initialized!
    2. at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit-1.7.2-R0.3-20131225.043511-4.jar:git...blablabla]
    3. at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit-1.7.2-R0.3...]
    4. at ooo.oooooo.oooo.MyCommandExecutor.<init>(MyCommandExecutor.java:31)
    5. ...

    error when the bukkit loads my plugin. My plugin worked well on other 1.7.2 versions before, but the latest development build throws this error. I have no idea why it throws it because it worked well before. And why throws it there when the "at: ---" texts show. I've got a "boot" mechanism like this:
    Code:java
    1. MyJavaPlugin extends JavaPlugin {
    2. private MyPluginCore _core;
    3. onEnable() {
    4. _core = new MyPluginCore(this);
    5. _core.Load();
    6. }
    7. ...
    8. }
    9.  
    10. MyPluginCore {
    11. private MyJavaPlugin _plugin;
    12. private MyCommandExecutor _executor;
    13. public MyPluginCore(MyJavaPlugin plugin) { _plugin = plugin; }
    14.  
    15. public void Load() {
    16. _executor = new MyCommandExecutor(this);
    17. }
    18. ...
    19. }
    20.  
    21. MyPluginExecutor extends CommandExecutor {
    22. private MyPluginCore _core;
    23. public MyPluginExecutor(MyPluginCore core) { _core = core; } // <--- the location of the error (line:31)
    24. @Override
    25. public onCommand { ... }
    26. ...
    27. }

    Anyone can help me what's wrong with it?
     
    mariosunny likes this.
  2. Offline

    epicfacecreeper

    It may be a problem with the bukkit build.

    Some slightly offtopic questions:
    Why are you not using your JavaPlugin class as your main class?
     
  3. Offline

    Davesan

    Just because it's better for me to use a clear class with no JavaPlugin stuff like "loadConfig()" and "saveConfig()" while I use another config handling mechanism. For example. And I only use the methods written by myself, so if I want to use something from the JavaPlugin class I get the _plugin varriable from the MyPluginCore class. So have no heavy reason, just more clear for me :)

    edit: and ty for your answer

    @epicfacecreeper It would be nice, but only some of my plugins throw this error, for example groupManager, Vault, iConomy and some of my other plugins work as good as before.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    Davesan

    Bump! Please, can somehelp solve this exception? I really want to use my plugin on 1.7.2!
     
  5. Offline

    SirPsp

    I get this with all R0.3 builds.
    R0.2 works fine but I would really like to know how to fix it for R0.3
     
  6. Offline

    epicfacecreeper

    Tons of people have this problem. I would recommend putting something on leaky.
     
  7. Offline

    RawCode

    downgrade build...

    this is very very obvious solution to problem.
     
  8. Offline

    Davesan

    I found what was the problem just forgot to post it!

    [SOLUTION]
    The PluginAlreadyInitialized error occours when the .jar file contains more than one subclass of JavaPlugin class. Accidentally I made my commandExecutor class to inheritate the JavaPlugin class too, so that was the reason why bukkit failed to load the plugin. OR I have found another forum post that talked about JavaPlugin class already implements the CommandExecutor class, may it caused the trouble that I implemented both the JavaPlugin and the CommandExecutor class for one class as the same time. Idk, but anyways, I will use the JavaPlugin class only once in all of my plugins from now :)
     
    Superior_Slime and JWhy like this.
  9. Well good for you :p - i am still having the exceptions for one of my plugins without anything that could hint at why, "except" for a totally unrelated plugin being mentioned in the stack trace shortly before the last (6 more) in the last "caused by" part... will soon try with plugins one by one, but this does not seem to be obvious.
     
  10. Offline

    dtclaybaugh

    Yeah it's still not working for me either.
     
  11. Actually i got mine solved - it was a jar export problem, with a locally stored manifest file accidentally a) being used at all b) referencing a plugin that got loaded twice that way (class path entry + server).

    Not sure what the side conditions / problems are with your setup...
     
  12. Offline

    dtclaybaugh

    I figured it out, I messed something simple up with the way I built the Listener. Typical dtclaybaugh.
     
  13. Just a quick tip for people who may still be having this problem, if you have 2 plugins with the same link to the main class (Like 1 plugin being 'com.rb2750.Main' and the other being the same) it will cause this problem. It is probably better if you have a separate package for each plugin like 'com.rb2750.PLUGIN.Main'.
     
    Davesan and DerDodl like this.
  14. Offline

    DerDodl

    Thank you very very much rb2750! (1000 Kisses :D) With you help by the package name, will my 2 plugins run! Before your help, it runs 1/2 Plugins! Thank you for your Thread!
     
Thread Status:
Not open for further replies.

Share This Page