Library conflict JSON Web Tokens and Encryption

0
When using both the JSON Web Tokens and Encryption modules in a project, I encouter the following library conflict: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString([B)Ljava/lang/String;     at com.auth0.jwt.JWTCreator.sign(JWTCreator.java:283)  Does someone know how to solve the conflict? Otherwise I will not use the Mendix encryption module and implement an existing Java AES encryption/decription implementation.
asked
7 answers
4

Hi,

It seems like you missing some required library for JWT-org.apache.commons.codec.binary?

-Andrej

 

EDIT:

I agree it is probably a library conflict. If you can not remove the older library version then the only solution would be to shadow one of them. Both maven and gradle have support for shadowing libs - https://github.com/johnrengelman/shadow

What I would suggest is to create a standalone maven/gradle project where you would implement your functionality that requires JWT.

Then package this project and all dependencies in a fat jar. And then you can use the shadow tools to rename the conflicting dependencies.

Finally add the jar to your userlib folder. 

answered
1

Hi Menno,

  I have downloaded both of these modules, and I see in my userlib the following jar files:

org.apache.servicemix.bundles.commons-codec-1.3.0

commons-codec-1.10.jar

It is the commons-codec jar file that contains the Base 64 encoding methods, so my suspicion is the older version of this jar file is being loaded before the newer version, which might contain the class you are looking for.  Try deleting the codec-1.3.0 jar as well as any other versions of the commons-codec in your userlib and then re-running.

answered
1

New version (1.2.2) has been released, which is compatible with the Encryption module. Can you leave a review if you are happy with it? If you have other recommendations for improvements, please let me know.

answered
0

Libraries are in there, just when adding the Encryption module, the JWT token is not generated anymore. Looks like a library conflict.

answered
0

Thanks guys! I did not have the time for this project to expirement, so I implemented a new java action for hashing strings. Don't need the encryption module anymore.

answered
0

Hi,

I have the similear issue, encryption module has this class GeneratePGPKeyRing, which take parameters 'PublicKey' and 'PrivateKey', while jwt module has the entities with the same names, during mendix build/deploy, the java class it chanes the name to PublicKeyParameter1 and PrivateKeyParameter1, but it does not change the custom code, so there is a compile error.

 

I am not sure the best way to handle it, for now i just rename the JWT entities to JWTPublicKey and JWTPrivateKey.

 

Thanks

Shannon

answered
0

New  version works!!! 

 

Thanks

Shannon

answered