Closed CMarcoo closed 5 months ago
It seems that you are not accessing HikariCP from the isolated loader. If you isolate it, you can only access it via its ClassLoader and not from the global one.
Try to remove the loaderId("hikari-id").isolatedLoad(true)
part.
Thanks I fixed my issues.
I think it would also be useful for other users to remind them that if their dependency has other compile dependencies, they need to also add them.
For instance, the cryptography and certificates dependency I'm using (bcpkix-jdk18on) also required "bcprov-jdk18on" and "bcutil-jdk18on".
It might be really useful for future users to tell them to always look at "compile dependencies" section of their libraries added from maven central.
Thanks for the help.
Facing a NoClassDefFoundError Using libby 2.0.0, Java 17 and Purpur 1.20.4 server.
I use dependency HikariCP, version 5.0.1. My plugin applies relocation using the maven shade plugin, and I also apply obfuscation using the yGuard plugin.
I call this code onEnable(), right before anything else.
java code
```java private void loadLibraries() { if (this.hikariCP != null || this.bcpkix != null || this.bukkitLibraryManager != null) { return; } this.bukkitLibraryManager = new BukkitLibraryManager(this); this.bukkitLibraryManager.addMavenCentral(); this.hikariCP = Library.builder() .groupId("com{}zaxxer") .artifactId("HikariCP") .version("5.0.1") .relocate("com{}zaxxer{}hikari","top{}cmarco{}lightlogin{}libs{}com{}zaxxer{}hikari") .loaderId("hikari-id") .isolatedLoad(true).build(); this.bcpkix = Library.builder() .groupId("org{}bouncycastle") .artifactId("bcpkix-jdk18on") .version("1.77") .relocate("org{}bouncycastle", "top{}cmarco{}lightlogin{}libs{}org{}bouncycastle") .loaderId("bcpkix-id") .isolatedLoad(true).build(); this.bukkitLibraryManager.loadLibraries(this.bcpkix, this.hikariCP); } ```Then I make relocations and remove any obfuscation from libby in my pom.xml
Even checked if packages are the same within the relocated libby jar, and my compiled software:
Yet, each time I get this error.
logs error
``` [23:25:20] [Server thread/INFO]: [LightLogin] Enabling LightLogin v1.0.0-SNAPSHOT [23:25:20] [Server thread/INFO]: [LightLogin] Loading library bcpkix-jdk18on [23:25:21] [Server thread/INFO]: [LightLogin] Downloaded library https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-jdk18on/1.77/bcpkix-jdk18on-1.77.jar [23:25:21] [Server thread/INFO]: [LightLogin] Downloaded library https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.2/asm-commons-9.2.jar [23:25:21] [Server thread/INFO]: [LightLogin] Downloaded library https://repo1.maven.org/maven2/org/ow2/asm/asm/9.2/asm-9.2.jar [23:25:21] [Server thread/INFO]: [LightLogin] Downloaded library https://repo1.maven.org/maven2/me/lucko/jar-relocator/1.7/jar-relocator-1.7.jar [23:25:21] [Server thread/INFO]: [LightLogin] Relocations applied to bcpkix-jdk18on-1.77.jar [23:25:21] [Server thread/INFO]: [LightLogin] Loading library HikariCP [23:25:21] [Server thread/INFO]: [LightLogin] Downloaded library https://repo1.maven.org/maven2/com/zaxxer/HikariCP/5.0.1/HikariCP-5.0.1.jar [23:25:21] [Server thread/INFO]: [LightLogin] Relocations applied to HikariCP-5.0.1.jar [23:25:21] [Server thread/INFO]: [LightLogin] Loaded config with language ENGLISH [23:25:21] [Server thread/ERROR]: Error occurred while enabling LightLogin v1.0.0-SNAPSHOT (Is it up to date?) java.lang.NoClassDefFoundError: top/cmarco/lightlogin/libs/com/zaxxer/hikari/HikariConfig at top.cmarco.lightlogin.I.A.