jargon2-api
jargon2-api copied to clipboard
Could not find appropriate jargon2Backend. Use either a service provider or define its class with -Dcom.kosprov.jargon2.spi.backend
Hi,
I am using your library in one of my minecraft plugins and I have this error: https://pastebin.com/WppHxW6w
Thanks for your help.
Hi,
Have you added the dependency to a backend? Like that:
<dependency>
<groupId>com.kosprov.jargon2</groupId>
<artifactId>jargon2-native-ri-backend</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
Yes, here is my pom.xml : http://pastebin.fr/82704
I would, first, remove the <scope>runtime</scope>
from the dependency. Maybe there's something fishy with shade or your runtime environment.
If that didn't work, I would try to define the jvm argument -Dcom.kosprov.jargon2.spi.backend=com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend
. You can set it in the surfire plugin if you like.
If that didn't work, I would statically define the class in the code:
jargon2Hasher()
.backend("com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend")
...
Sorry for my late reply but I tried the first and last solution but it didn't work. For the second I do not understand too much or I have to pass these arguments on Maven at the time of build?
Open your final jar and check if it has this content inside it: https://github.com/kosprov/jargon2-backends/tree/master/jargon2-native-ri-binaries-generic/src/main/resources
Yes, this is it https://www.noelshack.com/2021-05-4-1612464580-capture.jpg
Where do you run it? Which JVM type/version?
JVM version = 1.8.0_201 I compile my plugin with maven integrated in Intelij : Lifecycle > package. And I start my server with my .bat
I get the same error from Coldfusion.
I load the first backend jars, then jargon2-api-1.1.1.jar. This is OK by itself but then when I call the hasher function jargon2.jargon2Hasher() or jargon2.jargon2Hasher().backend("com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend") I get the same error: "Could not find appropriate jargon2Backend. Use either a service provider or define its class with -Dcom.kosprov.jargon2.spi.backend"
Then when I set this: -Dcom.kosprov.jargon2.spi.backend=com.kosprov.jargon2.nativeri.backend.NativeRiJargon2Backend in my JVM Arguments I get: "java.lang.NoClassDefFoundError Diagnose com/sun/jna/Pointer null"
What am I missing?
Please, clone the jargon2-examples
repository, minimal
branch, and follow the instructions on the README file.
https://github.com/kosprov/jargon2-examples/tree/minimal
This is the minimal example and I've just tested with openjdk 8 and 11 on Linux.
Try with this and let me know if it doesn't work.
Thank you for the quick response.
I did what you suggested (compiled the jargon2-examples-1.1.1.jar) and got the following info on the command line:
D:\projects\jargon2\jargon2-examples>echo -n "password" | java -jar target/jargon2-examples-1.1.1.jar somesalt -t 2 -m 16 -p 4 -l 24
Type: Argon2i
Iterations: 2
Memory: 65536 KiB
Parallelism: 4
Hash: 2380da7e054be36fd4bf868672598a1e8283fbd072c4533c
Encoded: $argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$I4DafgVL42/Uv4aGclmKHoKD+9ByxFM8
0.985 seconds
Verification ok
So far so good, but I am not sure how exactly this could help me.
On the other hand I have made some changes in my coldfusion project pom.xml - I explicitly included this dependency:
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
and the "Could not find appropriate jargon2Backend" error disappeared. So I am able now able to create the hasher object in ColdFusion.
However when I call this function: hasher.password(password).encodedHash(); the following exception occurs:
Typ | java.lang.UnsatisfiedLinkError Diagnose | Unable to load library 'argon2': Native library (win32-x86-64/argon2.dll) not found in resource path
So I am not sure where is ist dll supposed to be?
I have found the dll here: https://github.com/kosprov/jargon2-backends/blob/master/jargon2-native-ri-binaries-generic/src/main/resources/win32-x86-64/argon2.dll (it was not on my local maven repo) and I am wondering now - where should I put this dll to be found or am I doing something totally wrong?
Since the example code works as-is in your machine, you have a baseline to compare your project with.
net.java.dev.jna:jna:4.1.0
is a transitive runtime dependency, so it's already in the classpath. There is no need to declare it as a build-time dependency. See, for example, the dependency tree for the example project.
~/Dev/Projects/jargon2-examples$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.kosprov.jargon2:jargon2-examples >----------------
[INFO] Building jargon2-examples 1.1.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ jargon2-examples ---
[INFO] com.kosprov.jargon2:jargon2-examples:jar:1.1.1
[INFO] +- com.kosprov.jargon2:jargon2-api:jar:1.1.1:compile
[INFO] +- com.kosprov.jargon2:jargon2-native-ri-backend:jar:1.1.1:runtime
[INFO] | +- com.nativelibs4java:jnaerator-runtime:jar:0.12:runtime
[INFO] | | +- com.nativelibs4java:ochafik-util:jar:0.12:runtime
[INFO] | | \- net.java.dev.jna:jna:jar:4.1.0:runtime
[INFO] | \- com.kosprov.jargon2:jargon2-native-ri-binaries-generic:jar:1.1.1:runtime
[INFO] +- commons-cli:commons-cli:jar:1.4:compile
[INFO] \- commons-codec:commons-codec:jar:1.11:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.586 s
[INFO] Finished at: 2021-03-26T12:33:36+02:00
[INFO] ------------------------------------------------------------------------
That said, I think there's something wrong with how you package or run your code. I cannot support you further because I don't see your project.
https://github.com/kosprov/jargon2-backends/blob/master/jargon2-native-ri-binaries-generic/src/main/resources/win32-x86-64/argon2.dll
is packaged inside com.kosprov.jargon2:jargon2-native-ri-binaries-generic
which is, also, a runtime dependency.
Yes, you are right, the dll is there. I have unzipped the jar to make sure it is contained.
So it must have been correctly downloaded from Maven (Does it matter for this exactly if
jarArray = [
ExpandPath("/jars/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar"),
ExpandPath("/jars/com/nativelibs4java/ochafik-util/0.12/ochafik-util-0.12.jar"),
ExpandPath("/jars/com/nativelibs4java/jnaerator-runtime/0.12/jnaerator-runtime-0.12.jar"),
ExpandPath("/jars/com/kosprov/jargon2/jargon2-native-ri-backend/1.1.1/jargon2-native-ri-backend-1.1.1.jar"),
ExpandPath("/jars/com/kosprov/jargon2/jargon2-native-ri-binaries-generic/1.1.1/jargon2-native-ri-binaries-generic-1.1.1.jar"),
ExpandPath("/jars/com/kosprov/jargon2/jargon2-api/1.1.1/jargon2-api-1.1.1.jar")
];
javaLoader = CreateObject("component", "lib.shared.javaloader.JavaLoader").init(jarArray);
So maybe I somehow have to explicitly load the dll as well, otherwise it cannot be found. Could this dll be converted to a jar to be loaded separately? Although I this should not be necessary because with the other Java Binding phxql/argon2-jvm this is not needed and the dll is loaded without any issues. So I am trying to figure out what is different in the war the dll gets loaded in the other binding - perhaps because it does not happen at 'runtime'?
If you have any ideas I'll appreciate it!
I see jna-5.6.0
. Try not to deviate from the working example.
OK, I just tried both versions, but it seems like the jna version does not matter.
I would seek assistance from the Coldfusion support/community, at this point.
Do you have a new solution for my problem? :/
Please, do this: https://github.com/kosprov/jargon2-api/issues/8#issuecomment-807335083
If it works, then there's something wrong in your project poms or runtime.
It works well. I'll try to find out what's wrong then.
I tried clone and package both projects jargon2-api and jargon2-native-ri-backend only I didn't succeed to package jargon2-native-ri-backend would it be possible to have the .jar?
Go to the jargon2-examples
repo, make sure you have branch minimal
checked out (as you already did), and run:
mvn dependency:copy-dependencies
all jars will be copied to target/dependency
.
I did manage to download the dependencies. Then I recompiled my plugin without using maven or gradlle and I have the same problem :c