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

Nifi ExecuteScript Processor doesn't load dependent scripts from Module Directory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.0, 1.11.4
    • None
    • Variable Registry
    • None

    Description

      When running javascript using ExecuteScript Processor and providing dependent scripts path in module directory, dependent scripts objects are not available in scriptToRun. 

      Caused by: javax.script.ScriptException: TypeError: jsonata is not a function in <eval> at line number 3Caused by: javax.script.ScriptException: TypeError: jsonata is not a function in <eval> at line number 3 at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
      

      Using this test case.

      /**
       * Test script with additional dependent scripts
       * @throws Exception Any error encountered while testing
       */
      
      @Test
      public void testAdditionalDependentScripts() throws Exception{
          final TestRunner runner = TestRunners.newTestRunner(new ExecuteScript());
          runner.setValidateExpressionUsage(false);
          runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE, "ECMAScript");
          runner.setProperty(ScriptingComponentUtils.SCRIPT_FILE, "/path/to/nifi_sample_module/index.js");
          // Use basic manipulation to validate that EL is working
          runner.setProperty(ScriptingComponentUtils.MODULES, "/path/to/nifi_sample_module/node_modules/jsonata");
          // Also tried with below line
          runner.setProperty("jsonata","/path/to/nifi_sample_module/node_modules/jsonata/jsonata.js");
      
          runner.assertValid();
          runner.enqueue("{'name':'Some Name'}".getBytes(StandardCharsets.UTF_8));
          runner.run();
      }
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            vijendra07kulhade Vijendra Kulhade
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: