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

Nifi 1.13 Execute script raising issue "failed to process due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: SyntaxError: no viable alternative at input 'import' "

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.13.2
    • Fix Version/s: 1.14.0
    • Component/s: Core Framework, Core UI
    • Labels:
    • Environment:
      Ubuntu 18.04

      16 GB RAM

      intel i7 10th gen
    • Flags:
      Important

      Description

       

      import json
      from org.apache.commons.io import IOUtils
      from java.nio.charset import StandardCharsets
      from org.apache.nifi.processor.io import StreamCallback,InputStreamCallback, OutputStreamCallback
      
      class PyInputStreamCallback(InputStreamCallback):
       def __init__(self):
       self.json_content = {}
       def process(self, inputStream):
       text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
       print(" text %s " %text)
      
      class OutputWrite(OutputStreamCallback):
       def __init__(self, obj):
       self.obj = obj
       def process(self, outputStream):
       outputStream.write(bytearray(json.dumps(self.obj).encode('utf')))
      ###end class###
      flowfile = session.get()
      if flowfile != None:
       py_is = PyInputStreamCallback()
       session.read(flowfile, py_is)
       flowfile = session.write(flowfile, OutputWrite(py_is.json_content))
       session.transfer(flowfile, REL_SUCCESS)
       session.commit()
       session.close()
      

       

      2021-06-18 16:00:00,513 ERROR [Timer-Driven Process Thread-10] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=f2ea959c-c0e5-3698-42a5-19993fbdb19b] ExecuteScript[id=f2ea959c-c0e5-3698-42a5-19993fbdb19b] failed to process due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: SyntaxError: no viable alternative at input 'import' in <script> at line number 2 at column number 59; rolling back session: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: SyntaxError: no viable alternative at input 'import' in <script> at line number 2 at column number 59

      Above script is working fine in 1.11.4 nifi version, but it is raising exception in latest nifi version. can any one help me how to fix it.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              suresh_123 suresh b
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: