Giter Site home page Giter Site logo

Could not find appropriate jargon2Backend. Use either a service provider or define its class with -Dcom.kosprov.jargon2.spi.backend about jargon2-api HOT 23 OPEN

kosprov avatar kosprov commented on August 28, 2024
Could not find appropriate jargon2Backend. Use either a service provider or define its class with -Dcom.kosprov.jargon2.spi.backend

from jargon2-api.

Comments (23)

kosprov avatar kosprov commented on August 28, 2024

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>

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

Yes, here is my pom.xml : http://pastebin.fr/82704

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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")
    ...

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

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?

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

Yes, this is it https://www.noelshack.com/2021-05-4-1612464580-capture.jpg

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

Where do you run it? Which JVM type/version?

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

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

from jargon2-api.

ebreeze avatar ebreeze commented on August 28, 2024

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?

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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.

from jargon2-api.

ebreeze avatar ebreeze commented on August 28, 2024

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?

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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.

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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.

from jargon2-api.

ebreeze avatar ebreeze commented on August 28, 2024

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 runtime is set in pom.xml?)
But still at runtime it cannot be found.
My project is on ColdFusion, I don't know if you have experience with this rare language, that's why I did not post any code.
What is specific in the ColdFusion code is that it is using the JavaLoader (https://github.com/markmandel/JavaLoader) to load the jars (plus any dependencies) one by one:

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!

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

I see jna-5.6.0. Try not to deviate from the working example.

from jargon2-api.

ebreeze avatar ebreeze commented on August 28, 2024

OK, I just tried both versions, but it seems like the jna version does not matter.

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

I would seek assistance from the Coldfusion support/community, at this point.

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

Do you have a new solution for my problem? :/

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

Please, do this: #8 (comment)

If it works, then there's something wrong in your project poms or runtime.

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

It works well. I'll try to find out what's wrong then.

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

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?

from jargon2-api.

kosprov avatar kosprov commented on August 28, 2024

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.

from jargon2-api.

RMrenex avatar RMrenex commented on August 28, 2024

I did manage to download the dependencies. Then I recompiled my plugin without using maven or gradlle and I have the same problem :c

from jargon2-api.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.