Hi Martin,

There definitely should not be a NullPointerException, but the behavior you are 
describing is not how the processor is designed to work. The setup method that 
is running needs to load a specific script file from the filesystem. This 
method runs before any flow files arrive to the processor, so it is not able to 
evaluate dynamic attributes from the flow file. However, it can still use 
Expression Language to take advantage of variables defined in the variable 
registry or environment variables. 

To execute arbitrary scripts per flow file (which I really don’t recommend), 
you would need to use a static harness script which examines each incoming flow 
file, determines the respective script file, and executes it. 

Andy LoPresto
[email protected]
[email protected]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Oct 31, 2017, at 07:00, mvrabel <[email protected]> wrote:
> 
> Hi,
> 
> How I noticed this:
> I wanted to execute python scripts dynamically == using flowfile arguments,
> but I got FileNotFoundException.
> 
> Caused by: java.util.concurrent.ExecutionException:
> java.lang.reflect.InvocationTargetException
>        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
>        at java.util.concurrent.FutureTask.get(FutureTask.java:206)
>        at
> org.apache.nifi.controller.StandardProcessorNode.invokeTaskAsCancelableFuture(StandardProcessorNode.java:1465)
>        ... 9 common frames omitted
> Caused by: java.lang.reflect.InvocationTargetException: null
>        at sun.reflect.GeneratedMethodAccessor542.invoke(Unknown Source)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>        at java.lang.reflect.Method.invoke(Method.java:498)
>        at
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:137)
>        at
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:125)
>        at
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:70)
>        at
> org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:47)
>        at
> org.apache.nifi.controller.StandardProcessorNode$1$1.call(StandardProcessorNode.java:1307)
>        at
> org.apache.nifi.controller.StandardProcessorNode$1$1.call(StandardProcessorNode.java:1303)
>        ... 6 common frames omitted
> Caused by: org.apache.nifi.processor.exception.ProcessException:
> java.io.FileNotFoundException:  (No such file or directory)
>        at
> org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:160)
>        ... 15 common frames omitted
> Caused by: java.io.FileNotFoundException:  (No such file or directory)
>        at java.io.FileInputStream.open0(Native Method)
>        at java.io.FileInputStream.open(FileInputStream.java:195)
>        at java.io.FileInputStream.<init>(FileInputStream.java:138)
>        at java.io.FileInputStream.<init>(FileInputStream.java:93)
>        at
> org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:155)
>        ... 15 common frames omitted
> 
> 
> After some digging I found the possible cause:
> https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java
> 
> Line 288:
> scriptPath =
> context.getProperty(ScriptingComponentUtils.SCRIPT_FILE).evaluateAttributeExpressions().getValue();
> 
> From what I figured out from Matt's answer to a post (link below) there
> should be a flowfile argument inside "..evaluateAttributeExpressions()"
> https://community.hortonworks.com/questions/22448/apache-nifi-custom-processor-expression-language.html?childToView=22470#answer-22470
> 
> i.e.
> scriptPath =
> context.getProperty(ScriptingComponentUtils.SCRIPT_FILE).evaluateAttributeExpressions(<FLOW
> FILE>).getValue();
> 
> 
> Thanks,
> Martin
> 
> 
> 
> --
> Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/

Reply via email to