Max, which NiFi version are you using. Can you try adding the @Grab
annotation in your script declaring the commons-io dependency? IIRC, it was
added recently.

Andrew

On Sun, Apr 22, 2018, 7:38 AM Max Viazovskyi <[email protected]> wrote:

> Recently I needed to write custom script to override flow file content,
> when
> script was prepared I fount that it can be executed with ExecuteScript
> processor, but ExecuteGroovyScript fails to compile the same script, it
> shows the error: unable to resolve class import
> org.apache.commons.io.IOUtils.
> <
> http://apache-nifi-developer-list.39713.n7.nabble.com/file/t949/groovy_script_error.png>
>
>
> Script is the following:
> import org.apache.commons.io.IOUtils
> import java.nio.charset.*
>
> def flowFile = session.get()
> if (!flowFile) return
>
>
> flowFile = session.write(flowFile,
>     { inputStream, outputStream ->
>         def text = org.apache.commons.io.IOUtils.toString(inputStream,
> StandardCharsets.UTF_8)
>         text = text + '\n' + new Date()
>         outputStream.write(text.getBytes(StandardCharsets.UTF_8))
>     } as StreamCallback)
>
> session.transfer(flowFile, ExecuteScript.REL_SUCCESS)
>
> Also you could check it with template  GroovyScriptIsInvalid.xml
> <
> http://apache-nifi-developer-list.39713.n7.nabble.com/file/t949/GroovyScriptIsInvalid.xml>
>
>
> Thanks,
> Max
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>

Reply via email to