Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Need suggestion on Calling jar command thru Groovy Execute script Nifi processor failing

avatar
Explorer

Hi Team,

I am trying to calling jar utility in Nifi thru Execute Script processor groovy command like below.

#1. when i give without double quotes in command java params, its taking java class and executing and giving output. 

#2. when i try to add double quotes to params inside java command, its not giving any output, its giving null pointer exception and main method not calling.
#3. How to escape double quotes inside command and how to call the same in Nifi ?
#4. Guys, please suggest me one below use case.

flowFile = session.get()
if(!flowFile) return
try
{


def command = "java -cp \"/base_dir/poc/lib/dentine/*\" com.abc.xyz.Engine  -f=\"/base_dir/input/abc.xlsx\" -o=\"/base_dir/output/\"  -av_Log_Directory=\"/base_dir/logs/\" "

def process = command.execute()

def outputStream = new StringBuffer();
def errStream = new StringBuffer();
process.waitForProcessOutput(outputStream, errStream)

flowFile = session.putAttribute(flowFile, "process.exitValue()" , process.exitValue().toString())
session.transfer(flowFile, REL_SUCCESS)
}
catch(e)
{
flowFile = session.putAttribute(flowFile, "SCRIPT_EXECUTION", "FAILED")
flowFile = session.putAttribute(flowFile, "SCRIPT_ERROR_MESSAGE", e.getMessage())
session.transfer(flowFile, REL_FAILURE)
}

0 REPLIES 0