[SPIGOT-6822] Libraries loaded from Plugin Annotations fail classpath lookup Created: 30/Nov/21  Updated: 30/Nov/21  Resolved: 30/Nov/21

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Sander Knauff Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Maven, plugin-annotations
Environment:

Windows 10 Professional 21H1 19043.1348

java --version
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing) 
mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\Maven\bin\..
Java version: 16, vendor: AdoptOpenJDK, runtime: C:\Program Files\AdoptOpenJDK\jdk-16.0.0.36-hotspot
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" 

Attachments: Zip Archive example-projects-1.zip    
Version: CraftBukkit version 3334-Spigot-a5dea1c-a008701 (MC: 1.18) (Implementing API version 1.18-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

Loading libraries from plugin annotations seems not to work properly since updating to 1.18. Both HikariCP and Flyway throw an exception on load with this stack trace (library specific parts are of course different, but the root cause and exception message seem to be the same:

[23:45:28] [Server thread/INFO]: [Libtest] Enabling Libtest v1.0.0
[23:45:28] [Server thread/ERROR]: Error occurred while enabling Libtest v1.0.0 (Is it up to date?)
java.util.ServiceConfigurationError: org.slf4j.spi.SLF4JServiceProvider: org.apache.logging.slf4j.SLF4JServiceProvider n
ot a subtype
        at java.util.ServiceLoader.fail(ServiceLoader.java:593) ~[?:?]
        at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1244) ~[?:?]
        at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273) ~[?:?]
        at java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309) ~[?:?]
        at java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393) ~[?:?]
        at org.slf4j.LoggerFactory.findServiceProviders(LoggerFactory.java:104) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:147) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:139) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4
]
        at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:418) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:404) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:353) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:379) ~[slf4j-api-1.8.0-beta4.jar:1.8.0-beta4]
        at com.zaxxer.hikari.HikariConfig.<clinit>(HikariConfig.java:48) ~[?:?]
        at ooo.sansk.libtest.LibtestPlugin.onEnable(LibtestPlugin.java:22) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18-R0.1-SNAPSH
OT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18-R0.1-SNAPS
HOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:525) ~[spigot-1.18-R0.1-SNAPSHOT.ja
r:3334-Spigot-a5dea1c-a008701]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:439) ~[spigot-1.18-R0.1-SNAPSHOT.j
ar:3334-Spigot-a5dea1c-a008701]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:611) ~[spigot-1.18-R0.1-SNAPSHOT.jar:333
4-Spigot-a5dea1c-a008701]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:412) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3334
-Spigot-a5dea1c-a008701]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18-R0.1-SNAPSHOT.jar:33
34-Spigot-a5dea1c-a008701]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:993) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3334-Spigot-
a5dea1c-a008701]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:303) ~[spigot-1.18-R0.1-SNAPSHOT.jar:3334-
Spigot-a5dea1c-a008701]
        at java.lang.Thread.run(Thread.java:833) [?:?] 

Shading the libraries however does seem to work correctly.

 

Attached are two small projects. One implementing HikariCP with the annotations, the other using maven-shade. A running database to connect to is not required to reproduce the issue. The shaded variant seems to attempt to connect, while the annotation plugin does not reach that point.



 Comments   
Comment by Sander Knauff [ 30/Nov/21 ]

I can confirm this as fixed with the latest build. Thank you for the swift work!

Comment by Sander Knauff [ 30/Nov/21 ]

I don't think that is the case. The HikariCP version used in the examples is 5.0.0, which is the latest according to Maven Search.

If it were a version issue, wouldn't shading also break?

Comment by md_5 [ 30/Nov/21 ]

I think in this case the issue is Hikari (or a depend) is expecting a version of slf4j that is incompatible with the server version, 1.8.0-beta4. Can you check this and see if Hikari can be updated?

Generated at Wed Apr 02 10:57:25 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.