Conjur and Clojure

Hi there,

I am trying to make a super simple example of a Clojure application integrated with Conjur.
I am using the newly available Conjur Java API client available here: https://search.maven.org/artifact/com.cyberark.conjur.api/conjur-api/3.0.1/jar
and I added this line: [com.cyberark.conjur.api/conjur-api “3.0.1”] to my project.clj as it is suggested for “line”
You can find it attached (as .txt)project.txt (345 Bytes).
When I add this dependency and build my “Hello World” application again, I have the following error:
java.lang.NoSuchMethodError: ‘org.slf4j.helpers.FormattingTuple org.slf4j.helpers.MessageFormatter.arrayFormat(java.lang.String, java.lang.Object[])’, compiling:(ring/adapter/jetty.clj:22:3)
Exception in thread “main” java.lang.NoSuchMethodError: ‘org.slf4j.helpers.FormattingTuple org.slf4j.helpers.MessageFormatter.arrayFormat(java.lang.String, java.lang.Object[])’, compiling:(ring/adapter/jetty.clj:22:3)

Full trace attachedtrace.txt (6.2 KB)

Could there be something wrong with slf4j and the conjur api java client?

Many thanks,

JFC

Hey @JfcAtCyberArk,
I don’t know much about Clojure but this seems almost like there’s a discrepancy between logging frameworks (slf4j) and jetty, making me think that this is some srt of issue with a JDK and dependency discrepancy:

Caused by: java.lang.NoSuchMethodError: 'org.slf4j.helpers.FormattingTuple org.slf4j.helpers.MessageFormatter.arrayFormat(java.lang.String, java.lang.Object[])'
	at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:619)
	at org.eclipse.jetty.util.log.JettyAwareLogger.info(JettyAwareLogger.java:314)
	at org.eclipse.jetty.util.log.Slf4jLog.info(Slf4jLog.java:74)
	at org.eclipse.jetty.util.log.Log.initialized(Log.java:186)
	at org.eclipse.jetty.util.log.Log.getLogger(Log.java:288)
	at org.eclipse.jetty.util.log.Log.getLogger(Log.java:278)

While I’m not 100% sure, I would start looking into that first as it’s possible that when Conjur API tries to use the built-in logging mechanism that the underlying difference causes your error.

Hi @sgnn7,

Thanks for your answer!

I managed to build the application using dependency exclusions in the project.clj: project.txt (918 Bytes) but when the application is ran there is another error with the following docker logs: logs.txt (1.8 KB)
It comes from lines 16&17 of core.clj core.txt (668 Bytes) where the Conjur API client is instantiated.
I would like to make this sample project of Clojure + Conjur public when I’ll have a working example, but if you think it would be easier to share it now to have a look, let me know.

Thanks again for your help,

JFC

Hey @JfcAtCyberArk,
The problem arises here which points to the communication to the server failing for some reason but the rest seem to be following the logic paths. If I had to take a guess, I think there’s a problem with configured variables (like the SSL certificate or appliance url) or it’s possible that something with jaxrs.client is not working in this Closure env. As for sharing the project that’s up to you but I doubt I will be of better help there since I haven’t used Closure before.

Hi @sgnn7,

As always thanks for your answer!
I integrated https://github.com/cyberark/conjur-api-java in https://github.com/conjurdemos/pet-store-demo in a project and it worked (after some changes explained et the end of this post) with the exact same CONJUR_X parameters.

There is so obviously something wrong with Clojure.
I spent some cycles trying different options and trying to make sure it was not a code issue (I did not know Clojure before).
Here are my findings:

  • With the equivalent of Conjur() constructor:
    NPE error at login NPE_login.txt (1.7 KB)
  • With the equivalent of Conjur(username password) constructor:
    NPE error at login (same as before)
  • With the equivalent of Conjur(username password authnurl) constructor: NPE error at retrieveSecret
    NPE_retrieveSecret.txt (1.3 KB)

So the Null Pointer Exception arrises when getMandatoryProperties is called here for login.
Then if the above passes, there seem to be an issue with the ResourceClient

I am not experienced enough in Clojure dev to understand what is going wrong.
I guess it might come from the interoperability with Java that is maybe limited or from a missing dependency or just the implementation of the API client that is not compatible with Clojure.

As per the API client:
I really think there is an issue with what’s included in it.
I had to rework the dependencies both in the Clojure project and in the Java project
project.clj.txt pom.xml.txt so that I could build projects.
The issue was conflicting slf4j for Clojure and logback for Java (Springframework).
I think dependencies are introduced by this commit and as stated by slf4j doc, it should not have been done so.
I also had to had a javax activation dependency to make it work with the pet-store-demo so I am not sure it can easily be used as is.
What would be the best way to report this? Any suggestions? :slight_smile:
(I kept the logs if needed)

To sum up:
I am stucked on Clojure so I’ll wait until someone has an idea or if a Clojure expert can help me debug this.
I’d like to know what do you think about the issues I ran into with the conjur-api-java and know if I should report them.

Thanks for reading!

JFC