<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question executeScript not working in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/executeScript-not-working/m-p/211813#M173752</link>
    <description>&lt;P&gt;I am trying to run an ExecuteScript that should be taking in a json message and parsing the fields for further processing but I cannot get this to work. I ran a tester for ExecuteScript created by this author:&lt;/P&gt;&lt;P&gt;&lt;A href="https://funnifi.blogspot.com/2016/06/testing-executescript-processor-scripts.html" target="_blank"&gt;https://funnifi.blogspot.com/2016/06/testing-executescript-processor-scripts.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And it returned the following error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;cannot create an instance from the abstract interface org.apache.nifi.processor.io.StreamCallback&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I do not see the error in the script so could someone please assist with this:&lt;/P&gt;&lt;PRE&gt;    flowFile = session.get();

    if (flowFile != null) {

    var StreamCallback = Java.type("org.apache.nifi.processor.io.StreamCallback");
    var IOUtils = Java.type("org.apache.commons.io.IOUtils");
    var StandardCharsets = Java.type("java.nio.charset.StandardCharsets");
    var transformed_message = {};

    var error = false;
    var line = "ops_track";

    // Get attributes


    flowFile = session.write(flowFile, new StreamCallback(function (inputStream, outputStream) {


        // Read input FlowFile content


        var content = IOUtils.toString(inputStream, StandardCharsets.UTF_8); // message or content


        var message_content = {};


        try {


            message_content = JSON.parse(content);


            transformed_message.postID = (((message_content || {}).postID || "null"));


            transformed_message.contentType = (((message_content || {}).contentType || "null"));


               


                                    transformed_message.published = (((message_content || {}).published || "null"));


            transformed_message.crawled = (((message_content || {}).crawled || "null"));


            transformed_message.providerID = (((message_content || {}).providerID || "null"));


         


                                    line = line + " " + "postID=" + transformed_message.postID + ","


                     + "contentType=" + transformed_message.contentType + ","


                     + "published=" + transformed_message.published + ","


                     + "crawled=" + transformed_message.crawled + ","


                     + "providerID=" + transformed_message.providerID + ","


                                                                                + " value=" + "1" + " "


                     + time * 1000000 + "\n";


        


                               


            // Write output content


             if (transformed_message) {


                outputStream.write(line.getBytes(StandardCharsets.UTF_8));


            }


        } catch (e) {


            error = true;


            outputStream.write(content.getBytes(StandardCharsets.UTF_8));


        }


    }));


 


 


    if (error) {


        session.transfer(flowFile, REL_FAILURE)


    } else {


        session.transfer(flowFile, REL_SUCCESS)


    }


}
&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Aug 2018 21:32:45 GMT</pubDate>
    <dc:creator>hbnewbie</dc:creator>
    <dc:date>2018-08-08T21:32:45Z</dc:date>
  </channel>
</rss>

