Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: DSN is required (sentry) / reqwest4j on Alpine #2587

Closed
1 task
DarkCat09 opened this issue Jun 23, 2023 · 7 comments
Closed
1 task

Backend: DSN is required (sentry) / reqwest4j on Alpine #2587

DarkCat09 opened this issue Jun 23, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@DarkCat09
Copy link

Official Instance

Describe the bug

I'm trying to run Piped backend without Docker.
I'm using OpenJDK 17 on Alpine Linux, ./gradlew shadowJar executes without errors.
But piped.jar does not start, Sentry throws IllegalArgumentException even if I uncomment SENTRY_DSN in config.properties and/or set it to empty string.
I've checked that config is successfully read by Constants.class including SENTRY_DSN option.

To Reproduce

  1. git clone https://github.com/TeamPiped/Piped-Backend src && cd src
  2. ./gradlew shadowJar
  3. cp build/libs/piped-1.0-all.jar ../piped.jar && cp config.properties .. && cd ..
  4. java -jar ./piped.jar

Expected behavior

Piped server should start without errors.

Logs/Errors

Exception in thread "main" java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
	at io.sentry.Sentry.initConfigurations(Sentry.java:291)
	at io.sentry.Sentry.init(Sentry.java:210)
	at io.sentry.Sentry.init(Sentry.java:170)
	at io.sentry.Sentry.init(Sentry.java:156)
	at me.kavin.piped.Main.main(Main.java:38)

Browser, and OS with Version.

Alpine Linux Virtual v3.18

Additional context

No response

@DarkCat09 DarkCat09 added the bug Something isn't working label Jun 23, 2023
@DarkCat09
Copy link
Author

Okay, after modifying Main.java (I've replaced Constants.SENTRY_DSN with "") and installing package gcompat, it starts with another error, afaik related to Alpine's musl libraries:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class me.kavin.piped.consts.Constants
	at me.kavin.piped.Main.main(Main.java:61)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /tmp/libreqwest9381916879556712187.so: Error relocating /tmp/libreqwest9381916879556712187.so: gnu_get_libc_version: symbol not found [in thread "main"]
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
	at java.base/java.lang.Runtime.load0(Runtime.java:755)
	at java.base/java.lang.System.load(System.java:1953)
	at rocks.kavin.reqwest4j.ReqwestUtils.<clinit>(ReqwestUtils.java:34)
	at me.kavin.piped.utils.RequestUtils.sendGet(RequestUtils.java:23)
	at me.kavin.piped.consts.Constants.<clinit>(Constants.java:202)
	at me.kavin.piped.Main.lambda$main$0(Main.java:40)
	at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:176)
	at io.sentry.Sentry.init(Sentry.java:169)
	at io.sentry.Sentry.init(Sentry.java:156)
	at me.kavin.piped.Main.main(Main.java:38)
ThrottlingCache: 0 entries

@DarkCat09
Copy link
Author

Can I build libreqwest by myself, or maybe completely disable Sentry that loads this library?

@DarkCat09
Copy link
Author

Oh, I got it, libreqwest is loaded by Piped, not Sentry. So I need to modify and compile rocks.kavin.reqwest4j.ReqwestUtils, then use my version of the library in Piped build.

@FireMasterK
Copy link
Member

You can build libreqwest from https://github.com/TeamPiped/reqwest4j, maybe you could build it as a git dependency.

@DarkCat09
Copy link
Author

DarkCat09 commented Jun 24, 2023

@FireMasterK, thank you for the answer.
I've cloned the repository, built the rust library in reqwest-jni subdirectory, and run ./gradlew shadowJar (also tried build, jar tasks). There is no native libraries in the output JAR, only Java code.
Piped doesn't start with my JAR.
How to build it correctly?

@DarkCat09
Copy link
Author

I built reqwest-jni with cargo build --target x86_64-unknown-linux-musl --release and added the output .so library to reqwest4j-1.0.4-all.jar/META-INF/natives/linux/x86_64/libreqwest.so using 7z archiver.
Then compiled Piped with custom libreqwest4j JAR, and... it works!

@DarkCat09 DarkCat09 changed the title Backend: "DSN is required" when SENTRY_DSN set to empty string Backend: DSN is required (sentry) / reqwest4j on Alpine Jun 24, 2023
@DarkCat09
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants