terl / lazysodium-java

A Java implementation of the Libsodium crypto library. For the lazy dev.
https://github.com/terl/lazysodium-java/wiki
Mozilla Public License 2.0
134 stars 46 forks source link

Unable to load lazysodium with spring boot 3 and nested jars #133

Open ahazeltonNF opened 4 months ago

ahazeltonNF commented 4 months ago

Getting this exception during initialization:

2024-03-15T20:25:01.146920010Z Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
2024-03-15T20:25:01.146931299Z     at java.base/java.io.File.<init>(File.java:420)
2024-03-15T20:25:01.146933670Z     at com.goterl.resourceloader.ResourceLoader.urlToFile(ResourceLoader.java:588)
2024-03-15T20:25:01.146937295Z     at com.goterl.resourceloader.ResourceLoader.urlToFile(ResourceLoader.java:567)
2024-03-15T20:25:01.146948902Z     at com.goterl.resourceloader.ResourceLoader.extractFilesOrFoldersFromJar(ResourceLoader.java:227)
2024-03-15T20:25:01.146958719Z     at com.goterl.resourceloader.ResourceLoader.nestedExtract(ResourceLoader.java:174)
2024-03-15T20:25:01.147022290Z     at com.goterl.resourceloader.ResourceLoader.extractFromWithinAJarFile(ResourceLoader.java:98)
2024-03-15T20:25:01.147025093Z     at com.goterl.resourceloader.ResourceLoader.copyToTempDirectory(ResourceLoader.java:80)
2024-03-15T20:25:01.147026963Z     at com.goterl.resourceloader.SharedLibraryLoader.load(SharedLibraryLoader.java:53)
2024-03-15T20:25:01.147030026Z     at com.goterl.lazysodium.utils.LibraryLoader.loadBundledLibrary(LibraryLoader.java:134)
2024-03-15T20:25:01.147032942Z     at com.goterl.lazysodium.utils.LibraryLoader.loadLibrary(LibraryLoader.java:107)
2024-03-15T20:25:01.147037118Z     at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:34)

Worked correctly in SpringBoot 3.1.5 / Java 17 Debugged and the path is set to file:nested:/app/myapp-0.0.1-SNAPSHOT.jar. The “nested:” comes from the new https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html format and is not compatible with your implementation. Any recommendations?

sean-codevasp commented 4 months ago

+1 here. Any suggestion? or solution for this?