Skip to content

BungeeCord: NoSuchMethodError caused by mixed Adventure 4.x / 5.2.0 classes #623

Description

@siberanka

General information

Sonar fails to enable on BungeeCord with the following exception:

Exception encountered when loading plugin: Sonar
java.lang.NoSuchMethodError:
'java.util.Optional xyz.jonesdev.sonar.libs.kyori.adventure.util.Services.service(java.util.ServiceLoader, java.lang.Class)'

at xyz.jonesdev.sonar.libs.kyori.adventure.text.minimessage.MiniMessageImpl.(MiniMessageImpl.java:51)
at xyz.jonesdev.sonar.libs.kyori.adventure.text.minimessage.MiniMessage.miniMessage(MiniMessage.java:59)
at xyz.jonesdev.sonar.api.config.SonarConfiguration.loadValues(SonarConfiguration.java:244)
at xyz.jonesdev.sonar.common.boot.SonarBootstrap.initialize(SonarBootstrap.java:104)
at xyz.jonesdev.sonar.bungee.SonarBungeePlugin.onEnable(SonarBungeePlugin.java:34)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:375)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:339)

I enabled JVM class-loading logging to verify the source of the conflicting classes.

The Services class is loaded from Sonar-Bungee.jar:

xyz.jonesdev.sonar.libs.kyori.adventure.util.Services
source: file:/home/container/plugins/Sonar-Bungee.jar

However, MiniMessageImpl is loaded from Sonar's dynamically downloaded Adventure 5.2.0 library:

xyz.jonesdev.sonar.libs.kyori.adventure.text.minimessage.MiniMessageImpl
source: file:/home/container/plugins/Sonar/lib/net/kyori/adventure-text-minimessage/5.2.0/adventure-text-minimessage-5.2.0.jar-relocated-1242254762.jar

Adventure 5.2.0 MiniMessage expects Services.service(ServiceLoader, Class), but the Services class loaded from Sonar-Bungee.jar does not provide that method.

This appears to be an Adventure dependency/version conflict inside Sonar's relocated xyz.jonesdev.sonar.libs.kyori namespace.

Expected behavior:
Sonar should enable normally on BungeeCord.

Actual behavior:
Sonar fails during initialization with NoSuchMethodError.

Steps to reproduce

  1. Install the current Sonar-Bungee.jar on a BungeeCord-compatible proxy.
  2. Start the proxy with Sonar installed.
  3. Sonar downloads its Adventure 5.2.0 runtime libraries into plugins/Sonar/lib/.
  4. During initialization, xyz.jonesdev.sonar.libs.kyori.adventure.util.Services is loaded from Sonar-Bungee.jar.
  5. MiniMessageImpl is then loaded from the dynamically downloaded adventure-text-minimessage-5.2.0 JAR.
  6. MiniMessageImpl attempts to call Services.service(ServiceLoader, Class).
  7. Sonar fails to enable with java.lang.NoSuchMethodError.

The issue is reproducible after a full proxy restart and does not involve plugin reloading.

Sonar dump

A /sonar dump cannot be generated because Sonar fails during onEnable() before the plugin becomes usable.

The startup exception is:

java.lang.NoSuchMethodError:
'java.util.Optional xyz.jonesdev.sonar.libs.kyori.adventure.util.Services.service(java.util.ServiceLoader, java.lang.Class)'

If there is another way to generate a Sonar dump while the plugin fails during startup, I can provide it.

Additional information

JVM class-loading diagnostics confirm the conflict.

Services is loaded from:

xyz.jonesdev.sonar.libs.kyori.adventure.util.Services
source: file:/home/container/plugins/Sonar-Bungee.jar

MiniMessageImpl is loaded from:

xyz.jonesdev.sonar.libs.kyori.adventure.text.minimessage.MiniMessageImpl
source: file:/home/container/plugins/Sonar/lib/net/kyori/adventure-text-minimessage/5.2.0/adventure-text-minimessage-5.2.0.jar-relocated-1242254762.jar

The current Bungee module uses adventure-platform-bungeecord 4.4.1 and relocates net.kyori into xyz.jonesdev.sonar.libs.kyori, while Sonar dynamically loads Adventure 5.2.0 libraries into the same relocated namespace.

This appears to result in incompatible Adventure classes being mixed at runtime.

PacketEvents and other installed plugins use different package namespaces and are not supplying the xyz.jonesdev.sonar.libs.kyori.* classes involved in this exception.

I can also provide the full JVM class-loading log if needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions