servertap-io / servertap

ServerTap is a REST API for Bukkit/Spigot/Paper Minecraft servers
https://servertap.io
MIT License
225 stars 57 forks source link

Server Tap Plugin Incompatibility with EcoSkills #203

Closed fendyk closed 1 year ago

fendyk commented 1 year ago

New Issue Report: Server Tap Plugin Incompatibility with EcoSkills

Description

The 'Server Tap' plugin is incompatible with the 'EcoSkills' plugin, causing a java.lang.LinkageError related to the kotlin.Lazy interface. This issue might be resolved by updating the 'Server Tap' plugin to avoid shading Kotlin.

Error

[00:20:43] [Server thread/ERROR]: Error occurred while enabling EcoSkills v1.116.6 (Is it up to date?)
java.lang.LinkageError: loader constraint violation: loader 'EcoSkills v1.116.6.jar' @30474815 wants to load interface kotlin.Lazy. A different interface with the same name was previously loaded by 'ServerTap-0.4.0.jar' @1d582808. (kotlin.Lazy is in unnamed module of loader 'ServerTap-0.4.0.jar' @1d582808, parent loader java.net.URLClassLoader @7aec35a)
at com.willfp.ecoskills.libreforge.LibReforgePlugin.getLrcdbYml(LibReforge.kt:75) ~[EcoSkills v1.116.6.jar:?]
at com.willfp.ecoskills.libreforge.LibReforgePlugin.fetchConfigs(LibReforge.kt:164) ~[EcoSkills v1.116.6.jar:?]
at com.willfp.ecoskills.skills.CustomSkills.update(CustomSkills.java:40) ~[EcoSkills v1.116.6.jar:?]
at com.willfp.ecoskills.skills.Skills.update(Skills.java:77) ~[EcoSkills v1.116.6.jar:?]
at com.willfp.ecoskills.skills.Skills.<clinit>(Skills.java:85) ~[EcoSkills v1.116.6.jar:?]
at com.willfp.ecoskills.EcoSkillsPlugin.handleEnableAdditional(EcoSkillsPlugin.java:70) ~[EcoSkills v1.116.6.jar:?]

Possible Solution

Update the 'Server Tap' plugin to avoid shading Kotlin. Here's an example using Gradle:


plugins {
    id 'com.github.johnrengelman.shadow' version '7.1.2'
    id("org.jetbrains.kotlin.jvm") version "1.8.20-RC"
    id 'java'
}

sourceSets {
    main {
        kotlin {
            srcDirs += 'src/main/java'
            srcDirs += 'src/main/kotlin'
            srcDirs += 'src/main/kotlin/nameofpackage' // Add the new package here
        }
    }
}

shadowJar {
    archiveBaseName.set('Plugin name')
    archiveVersion.set('1.0.0')
    archiveClassifier.set('all')
    dependencies {
        exclude(dependency('org.jetbrains.kotlin:kotlin-stdlib')) // Exclude kotlin here
    }
}
phybros commented 1 year ago

@fendyk are you able to test the latest version? I'm sure it's still an issue but it would be nice to be sure

phybros commented 1 year ago

For reference, the error in ServerTap when excluding kotlin-stdlib is

[15:26:31 ERROR]: Error occurred while enabling ServerTap v0.5.2-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: kotlin/NoWhenBranchMatchedException
    at io.javalin.config.PrivateConfig.<init>(PrivateConfig.kt:22) ~[ServerTap-0.5.2-SNAPSHOT.jar:?]
    at io.javalin.config.JavalinConfig.<init>(JavalinConfig.kt:26) ~[ServerTap-0.5.2-SNAPSHOT.jar:?]
    at io.javalin.Javalin.<init>(Javalin.java:55) ~[ServerTap-0.5.2-SNAPSHOT.jar:?]
    at io.javalin.Javalin.create(Javalin.java:92) ~[ServerTap-0.5.2-SNAPSHOT.jar:?]
    at io.servertap.PluginEntrypoint.onEnable(PluginEntrypoint.java:98) ~[ServerTap-0.5.2-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:279) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]

Seems that javalin relies on that functionality

fendyk commented 1 year ago

I can confirm that the current issues have resolved by using the latest version of your plugin. thank you!

phybros commented 1 year ago

I'm honestly very surprised @fendyk!

I was sure it would still conflict with Eco.

Out of curiosity, which Java version are you using?

fendyk commented 1 year ago

I use OpenJDK 19.0.2 @phybros.

phybros commented 1 year ago

Thanks for the info! I'll close this issue out then