Vatuu / discord-rpc

Java Wrapper of the Discord-RPC Library for Discord Rich Presence.
MIT License
194 stars 42 forks source link

ExceptionInInitializerError - Linux (KDE neon) #16

Closed xp4u1 closed 5 years ago

xp4u1 commented 6 years ago

RichPresenceManager l. 48: DiscordRPC.discordInitialize("- id -", eventHandlers, true);

OS: Linux 4.13.0-45-generic (KDE neon) | Java: 10.0.1

DeJayDev commented 6 years ago

Interesting, I wrote this check and I didn't expect it to work 100% on Linux devices.

Let me see what I can do for you.

DeJayDev commented 5 years ago

Reopened to allow discussion, OP please try out this commit and let me know how it works out.

Darkxell commented 5 years ago

I'm having exactly the same issue, on x64 windows. Exception in thread "main" java.lang.ExceptionInInitializerError at com.darkxell.client.launchable.Launcher.main(Launcher.java:51) Caused by: java.lang.NullPointerException at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2314) at org.apache.commons.io.IOUtils.copy(IOUtils.java:2270) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2291) at org.apache.commons.io.IOUtils.copy(IOUtils.java:2246) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:150) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:22) ... 1 more

Launcher@51 DiscordRPC.discordInitialize("463408543572426762", DiscordEventHandlerForPMDMMO.createHandler(), true);

DiscordEventHandlerForPMDMMO.createHandler() return new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> { Logger.i("Connected to discord : " + user.username + "#" + user.discriminator); }).build();

Worth noting is that I have the discord-rpc.dll file correctly located in C:\Users-----\AppData\Local\Temp/discord-rpc/discord-rpc.dll

I would just add a Catch close for NullPointerException at the bottom of loadDLL() so it at least doesn't stop the current thread with a runtime error in class initialization. We'll work around this issue, but it sure is pretty annoying.

Thanks.

DeJayDev commented 5 years ago

Hey @Darkxell,

The published version is very experimental and should be going up with a new minor version patch very soon. Let me see what I can do in the meantime.

Vatuu commented 5 years ago

@Paul-Hoerenz @Darkxell Alright, we believe we've fixed the issues. Before we create a new release to address this issues, I've created an updated RPCTest.jar file. Please run it, and reply with the results here.

RunRPCTest.zip

Darkxell commented 5 years ago

Using it as a library seems to do exactly the same as the release... :/ Thanks for the fast reply tho ^^

Vatuu commented 5 years ago

Can you post the console log of what happens when you attempt to run the RPCTest.jar in this archive?

Darkxell commented 5 years ago

Exception in thread "main" java.lang.ExceptionInInitializerError at com.darkxell.client.launchable.Launcher.main(Launcher.java:50) Caused by: java.lang.NullPointerException at net.arikia.dev.drpc.DiscordRPC.copyFile(DiscordRPC.java:204) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:144) at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:16) ... 1 more

Vatuu commented 5 years ago

@Darkxell delete the discord-rpc folder in your temp directory, and try it again. If it still does not work, message me or Dejay on discord(Vatuu Komalia#1337 and DeJay#1337)

Darkxell commented 5 years ago

Sorry for not answering fast, I wasn't coding. I still get exactly the same error after deleting my discord-rpc folder, sorry ^^ I'll work around this issue in my project by having a separate thread that runs the discord rpc, I think it will be cleaner that the current code anyways.

If that's any help, this bug started appearing after I started using the java 1.8_181jre, I was previously using the 1.8_171jre with full encryption packages, and it was working fine. I don't think that should change anything but who knows.

Thanks for your answers!

DeJayDev commented 5 years ago

That's a really specific change, the underlaying issue is poor copying (fetching) the file. The issue lays right on this line (https://github.com/Vatuu/discord-rpc/blob/master/src/main/java/net/arikia/dev/drpc/DiscordRPC.java#L204) for your OS and unfortunately despite all my efforts VMWare refuses to start a virtual machine.

If you want to do me a favour and ensure you have permission to write to %localappdata%/Temp/.

Once again please remove the discord-rpc (if you've ran an older or indev version there should also be a discord-rpc.jar) and try to run the latest RPCTest provided by @Vatuu above. I believe there is a strange underlying issue here and I can offer a temp fix idea if you're feeling brave.

Darkxell commented 5 years ago

Good point. Sadly I tried to run eclipse with admin right (pretty sure it launches the jvm with admin rights), and nothing changes. Admin right doesn't seem to be required to write into %localappdata%/Temp/ anyways.

I tried running both the test jar above and the release jar. Everything works fine for the rest of my team tho, so I'll just reinstall everything someday and put it in a thread on it's own so it doesn't crash the application for me.

DeJayDev commented 5 years ago

If you're feeling brave, go ahead and reinstall the latest public JRE and JDK for Java 8. Happy to see everything works out for your team members. If they're interested in actually running the RPCTest and not just being greeted they have to set their current Discord Game to "Derp" and type "test" in the terminal.

Darkxell commented 5 years ago

Oddly enough, running the jar as a game as you've said works even on my machine...

DeJayDev commented 5 years ago

Well, the window will always open regardless of the status of the library. The recommended way of running RPCTest is through a terminal command java -jar RPCTest.jar

Darkxell commented 5 years ago

I meant the discord rpc in command line. The score increases as it should in discord.

DeJayDev commented 5 years ago

That's enough reason to believe the RPC should be fine within your app, be sure to update to 1.5.1 and let me know how it goes.

Vatuu commented 5 years ago

Version 1.5.1 has been released. https://github.com/Vatuu/discord-rpc/releases/tag/1.5.1 As the issue is apparently fixed now, please open a new issue if further complications occur.