nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Grande <apere...@gmail.com>
Subject Re: ExecuteGroovyScript processor unable to resolve IOUtils
Date Sun, 22 Apr 2018 12:26:26 GMT
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 <iluvtechno@gmail.com> 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/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message