Solved java.lang.InstantiationException: null

Discussion in 'Plugin Development' started by jortpepe, Jul 28, 2017.

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

    jortpepe

    Hi! So I'm coding a plugin and when I started my server I received the following error:
    https://pastebin.com/kmgdLDxm
    It seems like something is wrong at line 122 in my PlayerManager.java so here is the class in which the error occurs: https://pastebin.com/cxu2vNBB
    I read at docs.oracle.com that this error could be thrown when:
    the class object represents an abstract class, an interface, an array class, a primitive type, or void.
    the class has no nullary constructor.
    However I have no idea whats going wrong. Any help?
     
  2. Offline

    timtower Ninja on the waves Moderator

    @jortpepe Could you post the class that is represented by the type G?
     
  3. Offline

    jortpepe

    Oh sorry of course! Totally forgot that haha. Here is the class: https://pastebin.com/Czrvd7kM
     
  4. Offline

    timtower Ninja on the waves Moderator

    @jortpepe My bet would be that it doesn't like it that you implement Player.
     
  5. Offline

    jortpepe

    That indeed might be it. However without the implement I get the following error for most of the methods:
    The method setStatistic(Statistic, EntityType, int) of type GeneralPlayer must override or implement a supertype method. I am now removing all the @overrides to see if it works without them. I will keep you updated!
     
  6. Offline

    AlvinB

    @timtower
    I don't think that's the case. This is an internal reflection exception, which I doubt Bukkit would throw.

    @jortpepe
    What if instead of Class.newInstance(), you do Class.getConstructor().newInstance()? I think that should give a bit more info on the error.
     
  7. Offline

    jortpepe

    @AlvinB @timtower Im sorry but I just found out that it was a database related issue. It had nothing to do with the implement player because without the implement the @overrides wouldn't work and they are needed of course. When I tried to use Classname.getConstructor().newInstance() I would get even more errors than before so that also wasn't an option for me hahaha. Thanks for all the help though! Really appreciated! (If you are interested in the database issue: the database wasn't adding the players to the desired collection. This means that the plugin was never able to retrieve data out of the collection and would return null which the plugin couldn't handle.) It's all fixed now and the plugin almost runs smoothly! (except for even more database issues! Yes its my first time working with a database)
     
  8. Offline

    AlvinB

    @jortpepe
    Well, Class.getConstructor().newInstance() might've thrown more errors, but that would've helped us diagnose the issue! :p

    Anyways, glad that you solved it.
     
    jortpepe likes this.
Thread Status:
Not open for further replies.

Share This Page