Support Questions

Find answers, ask questions, and share your expertise

Building Apache Nifi Python Processors

avatar
Explorer

ERROR [python-log-97916] py4j.java_gateway There was an exception while executing the Python Proxy on the Python Side.

Traceback (most recent call last):

  File "C:\Nifi\nifi-2.0.0-M4\python\framework\py4j\java_gateway.py", line 2466, in _call_proxy

    return_value = getattr(self.pool[obj_id], method)(*params)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Nifi\nifi-2.0.0-M4\.\python\framework\Controller.py", line 75, in createProcessor

    processor = processorClass(jvm=self.gateway.jvm)

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: WriteHelloWorld.__init__() got an unexpected keyword argument 'jvm'

2024-07-19 11:08:55,680 ERROR [Initialize Python Processor ca359d33-0190-1000-2b29-ff0f5ad6577a (WriteHelloWorld)] o.a.n.py4j.StandardPythonProcessorBridge Failed to load code for Python Processor ca359d33-0190-1000-2b29-ff0f5ad6577a (WriteHelloWorld). Will try again in 64000 millis

py4j.Py4JException: An exception was raised by the Python Proxy. Return Message: Traceback (most recent call last):

  File "C:\Nifi\nifi-2.0.0-M4\python\framework\py4j\java_gateway.py", line 2466, in _call_proxy

    return_value = getattr(self.pool[obj_id], method)(*params)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Nifi\nifi-2.0.0-M4\.\python\framework\Controller.py", line 75, in createProcessor

    processor = processorClass(jvm=self.gateway.jvm)

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: WriteHelloWorld.__init__() got an unexpected keyword argument 'jvm'

2 REPLIES 2

avatar
Super Guru

Hi ,

Can you post your python processor code? Also what version of Nifi , Java , Python are you you using?

avatar
Explorer

i used this code for testing 

from nifiapi.flowfiletransform import FlowFileTransform, FlowFileTransformResult

class WriteHelloWorld(FlowFileTransform):
    class Java:
        implements = ['org.apache.nifi.python.processor.FlowFileTransform']
    class ProcessorDetails:
        version = '0.0.1-SNAPSHOT'

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def transform(self, context, flowfile):
        return FlowFileTransformResult(relationship = "success", contents = "Hello World", attributes = {"greeting", "hello"})

python 3.11 , java 21 and Apache nifi 2.0.0 M4