Search code examples
groovyjwtapache-nifi

Nifi 1.19 Groovy: Jwts.builder(): jjwt jar missing


I'm using NiFi 1.19 with Java 11. In ExecuteScript Groovy

import io.jsonwebtoken.*

String jwtToken = Jwts.builder()

gives me an exeption: groovy.lang.MissingPropertyException: No such property: Jwts for ...

I take a closer look at the jar files of the current version and older versions and found

NiFi 1.12

nifi-1.12.0\work\nar\framework\nifi-framework-nar-1.12.0.nar-unpacked\NAR-INF\bundled-dependencies

  • jackson-core-2.9.10.jar
  • jackson-databind-2.9.10.jar
  • jackson-annotations-2.9.10.jar
  • jjwt-0.6.0.jar

NiFi 1.19

nifi-1.19.0\work\nar\framework\nifi-framework-nar-1.19.0.nar-unpacked\NAR-INF\bundled-dependencies

  • jackson-core-2.14.0.jar
  • jackson-databind-2.14.0.jar
  • jackson-annotations-2.14.0.jar

CONCLUSION

So it seems that jjwt-x.y.z.jar is missing

  • is this the correct assumption or am I wrong?
  • which version of jjwt belongs to jackson 2.14? (in the latest download package I found jjwt 0.9.1 with jackson 2.9.6)
  • where do I have to copy the jar file? Into the "./extensions" directory and reference it in ExecuteScript Attribute "Module Directory"?

Solution

  • The jjwt JAR is a transitive dependency of the framework JAR(s), some of which are themselves dependencies (or transitive dependencies) of the nifi-scripting-nar. This means you can't count on any of those transitive dependencies being available for use by ExecuteScript, only those that are explicit dependencies in the nifi-scripting-nar (and/or nifi-scripting-processors) POM.

    You can download it yourself and use the Module Directory property to point at the JAR(s) or directories containing the JARs. If you're using Groovy you can also use @Grab to dynamically download it and add it to the classpath, I have a blog post illustrating how to do that.