Closed cadergator10 closed 2 days ago
Strange, I tried building a reduced version of your build.gradle file, and the jar included slf4j as expected. Can you give link to the full project? Also need to know what Gradle version you're using, since your file uses a lot of deprecated/removed functionality.
It would be gradle 4.9, and in a couple hours I'll try and get the full project to you
Note: you might need to replace only the build.gradle file with what i pasted above, since it hasn't been updated
I cloned your provided link, replaced build.gradle with version from comment, ran gradle jar
and checked resulting jar files. Both of them include org/slf4j/LoggerFactory.class as expected. Looks like this issue is specific to minecraft/forge.
Here are other people experiencing exactly the same issue (slf4j is present in jar but not found by class loader):
So forge must be doing something stupid with class loading... You can probably use the "shadow" plugin to remap slf4j within your jar: https://gradleup.com/shadow/configuration/relocation/ But I would recommend asking forge devs what to do in this situation. As a last resort - you can clone this library, delete all uses of "log" and "Logger" (there aren't that many actually) and recompile.
Anyway, closing this issue since it is unrelated to java-websocket, good luck with your project!
Just double checking: the gradle program "publish" works right? That's what I used to get the mod jar
Yes, in fact all 3 jar files are identical
@cadergator10 Out of curiosity I checked and it's pretty easy to remove slf4j from this library, see my fork https://github.com/PhilipRoman/Java-WebSocket/commit/a8d43d1dd2e7447f0ad0440e298427b8884e6d3e So you have a backup option available
@cadergator10 Out of curiosity I checked and it's pretty easy to remove slf4j from this library, see my fork PhilipRoman@a8d43d1 So you have a backup option available
Oh perfect! I am definitely in need of it now, since I found out you can open the jar archive with 7zip and, yeah, it is included in the fatjar. but the class is still never found running the mod. Thank you for the help!
@cadergator10 Out of curiosity I checked and it's pretty easy to remove slf4j from this library, see my fork PhilipRoman@a8d43d1 So you have a backup option available
For some reason, now I'm getting a "[java.lang.ThreadGroup:uncaughtException:1052]: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;" error now, both in the ide and the mod
Edit: I built the project using jdk 21 -_- lol... trying with 1.8. i think that'll fix it
Yes, this happens because in Java 9 they added overrides to ByteBuffer which return a more specific type. So code compiled with jdk >= 9 will fail to run on java <= 8. To avoid, either compile with older jdk, or pass --release to javac (in Gradle, that should be targetCompatibility setting)
Describe what you would like to know or do I'm trying to add the websocket client to a minecraft mod, but for some reason my implementation of the fatjar doesn't add it no matter what I do
Describe the solution you'd considered multiple different ways of adding a library to a fatjar, both compile and implementation
Additional context Crash report:
`---- Minecraft Crash Report ---- // Uh... Did I do that?
Time: 9/24/24 1:47 PM Description: Exception in server tick loop
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Advanced Base Security (advancedbasesecurity) Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.java_websocket.drafts.Draft_6455.(Draft_6455.java:113)
at org.java_websocket.drafts.Draft_6455.(Draft_6455.java:210)
at org.java_websocket.drafts.Draft_6455.(Draft_6455.java:198)
at org.java_websocket.drafts.Draft_6455.(Draft_6455.java:178)
at org.java_websocket.client.WebSocketClient.(WebSocketClient.java:184)
at com.cadergator10.advancedbasesecurity.util.WebsocketHandler.(WebsocketHandler.java:37)
at com.cadergator10.advancedbasesecurity.AdvBaseSecurity.init(AdvBaseSecurity.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:749)
at net.minecraftforge.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:108)
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:338)
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:219)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:101)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 43 more
A detailed walkthrough of the error, its code path and all known details is as follows:
-- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 11 (amd64) version 10.0 Java Version: 1.8.0_401, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1111762368 bytes (1060 MB) / 1261961216 bytes (1203 MB) up to 7578058752 bytes (7227 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.5.2860 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
The build.gradle: