问题
I have written a python script to just compare to strings and putting attribute in the flowfile. But while handling exceptions, I am getting below error always and my flowfile is stuck in the queue with ExecuteScript Processor with below exception:
2020-02-07 18:15:26,049 ERROR [Timer-Driven Process Thread-7] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=0fdb3d0f-b361-3b31-faf8-fce2dc707591] ExecuteScript[id=0fdb3d0f-b361-3b31-faf8-fce2dc707591] failed to process due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.apache.nifi.processor.exception.FlowFileHandlingException: org.apache.nifi.processor.exception.FlowFileHandlingException: StandardFlowFileRecord[uuid=e263f921-8cf3-4bd0-8190-0b3864cc3e78,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1581055293097-1, container=default, section=1], offset=416137, length=1236],offset=0,name=name=test_1/test_2/my_entity/rrp_26_dec_parent_rrp_child/dd_rrp_26_dec_parent_rrp_child_1027102c-f97a-11aad-bpo7-bd9840e139df000.csv,size=1236] is not known in this session (StandardProcessSession[id=22]) in at line number 32; rolling back session: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.apache.nifi.processor.exception.FlowFileHandlingException: org.apache.nifi.processor.exception.FlowFileHandlingException: StandardFlowFileRecord[uuid=e263f921-8cf3-4bd0-8190-0b3864cc3e78,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1581055293097-1, container=default, section=1], offset=416137, length=1236],offset=0,name=name=test_1/test_2/my_entity/rrp_26_dec_parent_rrp_child/dd_rrp_26_dec_parent_rrp_child_1027102c-f97a-11aad-bpo7-bd9840e139df000.csv,size=1236] is not known in this session (StandardProcessSession[id=22]) in at line number 32 org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.apache.nifi.processor.exception.FlowFileHandlingException: org.apache.nifi.processor.exception.FlowFileHandlingException: StandardFlowFileRecord[uuid=e263f921-8cf3-4bd0-8190-0b3864cc3e78,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1581055293097-1, container=default, section=1], offset=416137, length=1236],offset=0,name=test_1/test_2/my_entity/rrp_26_dec_parent_rrp_child/dd_rrp_26_dec_parent_rrp_child_1027102c-f97a-11aad-bpo7-bd9840e139df000.csv,size=1236] is not known in this session (StandardProcessSession[id=22]) in at line number 32 at org.apache.nifi.processors.script.ExecuteScript.onTrigger(ExecuteScript.java:239) at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1165) at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:203) at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
****The below is the script:****
enter code here
import java
import os
from java.sql import SQLException
from java.lang import Throwable
flowFile = None
try:
flowFile = session.get()
if flowFile != None:
originalFilname = flowFile.getAttribute('sourceFileName')
pathFileNameEntity = originalFilname.rsplit('_', 1)[0]
fileNameEntity = pathFileNameEntity.rsplit('/', 1)[-1]
realTimeEntityString = \
flowFile.getAttribute('my.entity.name')
for entityName in realTimeEntityString.split(','):
ename = 'rr_' + entityName.lower()
if ename == fileNameEntity.lower():
cEntityName = entityName
flowFile = session.putAttribute(flowFile,
'current.entity.ename', str(cEntityName))
session.transfer(flowFile, REL_SUCCESS)
else:
flowFile = session.putAttribute(flowFile, 'errorMessage'
, 'Issue with RT Entity Names')
session.transfer(flowFile, REL_FAILURE)
except Exception, e:
if flowFile != None:
flowFile = session.putAttribute(flowFile, 'errorMessage',
str(e))
session.transfer(flowFile, REL_FAILURE)
except Throwable, e:
if flowFile != None:
flowFile = session.putAttribute(flowFile, 'errorMessage',
str(e))
session.transfer(flowFile, REL_FAILURE)
Can anybody help me understand why it is failing going into except block even if exception did not occur. Is it Syntax error?
来源:https://stackoverflow.com/questions/60116184/org-apache-nifi-processor-exception-flowfilehandlingexception-is-not-known-in-t