Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-11700

Java 17 Nashorn standalone support

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Motivation

      Nashorn was removed with the release of JDK 15 and is unavailable in Java 17. Standalone Nashorn or a scripting engine alternative is required for scripting processors to run ECMAScript.

      Related Tickets

      Requires:

      • Support building with version 61 class files [1]

      Past Related Tickets:

      • Support building with Java 17 [2]

      Versions

      • openjdk 17.0.7 2023-04-18
      • NiFi 2.0.0-SNAPSHOT (fork) [3]
      • Maven 3.9.2 (mvn) [4]

      Setup

      • Clone NiFi repo v2.0.0
      • Add Nashorn standalone (see fork) [3]

       

      <dependency>
                  <groupId>org.openjdk.nashorn</groupId>
                  <artifactId>nashorn-core</artifactId>
                  <version>15.4</version>
                  <scope>provided</scope>
      </dependency>
      
      • Add Nashorn to the script engine (see fork) [3]
      • Build NiFi
      • Run NiFi

       

      NiFi crashed after startup, nifi-app.log contains the relevant errors.

      Adding standalone Nashorn to NiFi caused the following errors to occur:

       

      Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 61
          at org.objectweb.asm.ClassReader.<init>(ClassReader.java:196)
          at org.objectweb.asm.ClassReader.<init>(ClassReader.java:177)
          at org.objectweb.asm.ClassReader.<init>(ClassReader.java:163)
          at org.objectweb.asm.ClassReader.<init>(ClassReader.java:284)
          at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:932)
          at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:917)
          at org.eclipse.jetty.annotations.AnnotationParser.lambda$parseJar$2(AnnotationParser.java:876)
          ... 9 common frames omitted
       
      Caused by: java.lang.RuntimeException: Error scanning entry com/fasterxml/jackson/core/io/doubleparser/FastDoubleSwar.class from jar file:///<path>/<to>/<nifi>/nifi-assembly/target/nifi-2.0.0-SNAPSHOT-bin/nifi-2.0.0-SNAPSHOT/work/jetty/nifi-standard-content-viewer-2.0.0-SNAPSHOT.war/webapp/WEB-INF/lib/jackson-core-2.15.2.jar
          at org.eclipse.jetty.annotations.AnnotationParser.lambda$parseJar$2(AnnotationParser.java:880)
          at java.base/java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:3215)
          at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
          at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotgradleationParser.java:872)
          at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:835)
          at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159)
          at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:455)
          at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
          at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
          at java.base/java.lang.Thread.run(Thread.java:833)
       
      

       

      These errors were caused by NiFi not supporting the building of version 61 class files (class files in packages built with Java 17).

       

      [1] https://issues.apache.org/jira/browse/NIFI-11701

      [2] https://issues.apache.org/jira/browse/NIFI-9281

      [3] https://github.com/Aerilym/nifi/tree/nashorn

      [4] https://maven.apache.org/install.html

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Aerilym Ryan Miller
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: