1.8.8 NoSuchMethodError in Log4j when trying to use Javacord

Discussion in 'Spigot Plugin Development' started by Fozzie1000, Jul 12, 2021.

  1. I am trying to add Discord functionality through javacord. I managed to get Javacord imported and can run, however I get the following error after trying to call the .login method.
    Code (Java):
    java.lang.NoSuchMethodError: 'void org.apache.logging.log4j.Logger.debug(java.lang.String, java.lang.Object, java.lang.Object)'
            at org.javacord.core.DiscordApiBuilderDelegateImpl.login(DiscordApiBuilderDelegateImpl.java:186) ~[javacord-3.3.2-shaded.jar:?]
            at org.javacord.api.DiscordApiBuilder.login(DiscordApiBuilder.java:41) ~[javacord-3.3.2-shaded.jar:?]
            at club.bridgepractice.Bridge.Bridge.onEnable(Bridge.java:124) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    This error happens because the code inside the login method contains a call to a Log4j logger with a string and two objects.

    I have a feeling that this is happening because I have multiple versions of log4j in my class path, one from spigot and one from the shaded javacord jar. The spigot one has a method with the signature (String, Object...) and the javacord has one with the signature (String, Object Object). To my knowledge of java either should work.

    Any help is appreciated.
  2. foncused

    Moderator Patron

    You can try relocating or excluding conflicting dependency versions with Maven.


    You also might want to try including a specific version of Log4j: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core