Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

No viable alternative at input '' .

Highlighted

No viable alternative at input '' .

Explorer

I am trying to read zip file in nifi execute processor and I am using python as a scripting language. When I run the script it throws no viable alternative input at line 25 (flowFile = session.get()). What is the real cause behind this.

Here is my script

from zipfile import ZipFile
from org.apache.nifi.processor.io import InputStreamCallback
import java.io
import json
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback 
class ReadVersion(InputStreamCallback):
  def __init__(self):
    self.flowFile = None
    self.version = ''
    self.error = ''
  def process(self,inputStream):
    try:
      zipname = self.flowFile.getAttribute('filename')
      zippath = self.flowFile.getAttribute('absolute.path')
      zfile = zipfile.ZipFile(zippath+zipname)
      with zipFile(zfile,'r') as zip:
        pageview = zip.read('pageview.json').decode("utf-8")
        pageview = json.loads(clients)
        pam = zip.read('pam.json') 
        pam= json.loads(Company.decode("utf-8") ) 

flowFile = session.get()
if (flowFile != None):
  callback = ReadVersion()
  callback.flowFile = flowFile
  session.read(flowFile, callback)
  if (callback.version != ''):
    flowFile = session.putAttribute(flowFile,'MSVersion',callback.version)
    session.transfer(flowFile, REL_SUCCESS)
  if (callback.error == 'error'):
    session.transfer(ff, REL_FAILURE)
1 REPLY 1
Highlighted

Re: No viable alternative at input '' .

@Vivek Singh

Try this instead,

def flowFile = session.get(1)
Don't have an account?
Coming from Hortonworks? Activate your account here