Nifi 1.5.0 I'm try execute this Python Script in ExecuteScript processor:
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
import xml.etree.ElementTree as ET
class PyStreamCallback(StreamCallback):
def __init__(self):
pass
def process (self, inputStream, outputStream):
xmlRaw = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
tree = ET.fromstring(xmlRaw)
root = tree.getroot()
xmlFix = ET.tostring(root, encoding='utf8', method='xml')
outputStream.write(bytearray(xmlFix))
flowFile = session.get()
if (flowFile != None):
#callback = PyStreamCallback(flowFile)
#session.read(flowFile, callback)
flowFile = session.write(flowFile, PyStreamCallback())
session.transfer(flowFile, REL_SUCCESS)
session.commit()
And I have error:
ExecuteScript[id=3c68eecc-0172-1000-ffff-ffff82be9cc3] Failed to process session due to javax.script.ScriptException: org.xml.sax.SAXException: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser in <script> at line number 21: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.xml.sax.SAXException: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser in <script> at line number 21
xml.etree.ElementTree not supported in Jython or it Nifi configuration error?