Support Questions

Find answers, ask questions, and share your expertise

Unable to execute ExecuteStreamCommand processor in NIFI

avatar
Contributor

Hello,
I am using NIFI in HDP sandbox to execute a java jar. This jar contains a simple Hbase which creates a table based on argument supplied from NIFI instance.

I used ExecuteStreamComand processor to call this jar with properties as said shown

26442-executestreamcommandproperties.png

but it throws error as follows:

26443-error-dialog.png

I tried again but by changing the Working Directory to:

 root/IdeaProjects/mavenhbasetest/target/

I now get the following error :

26444-error-2.png

Fyi, I tried testing the jar in shell and it works fine.

26445-hbasetest.png


Could someone provide me help on where am I going wrong?

Thanks and regards,
Jasim

1 ACCEPTED SOLUTION

avatar
Master Guru

It's easiest to run your commands in a shell script.

What I do is create a shell script, make sure it has all the permissions you need and set any CLASSPATH, JAVA_HOME and other environment variables.

Then I just call it like

/opt/mydir/myshell.sh

This is 777 and will call my java via java -jar ...

Build a jar and run it that way.

Or wrap it in a custom processor.

https://community.hortonworks.com/articles/73811/trigger-sonicpi-music-via-apache-nifi.html

View solution in original post

5 REPLIES 5

avatar
Super Guru

Is NiFi running as root? Perhaps it does not have the permission to read the JAR file. You could try copying the JAR file to /tmp/ and reference it there.

avatar
Contributor

@Josh Elser I did make change as you said and also added nifi in sudoers as root. But, now I am getting JNI Error:

26458-jni-error.png

26459-nifi-root-permission-sudoers.png

Tried even after chown as nifi:nifi to folder where java is stored.

But I still get the sam JNI error.

Where am I going wrong?

Thanks

avatar
Super Guru

Please read the error message. The HBase client has a number of dependencies that it requires to function. You have not included them on the classpath of your application.

Please use the output of `hbase classpath` to see what all is required.

avatar
Master Guru

It's easiest to run your commands in a shell script.

What I do is create a shell script, make sure it has all the permissions you need and set any CLASSPATH, JAVA_HOME and other environment variables.

Then I just call it like

/opt/mydir/myshell.sh

This is 777 and will call my java via java -jar ...

Build a jar and run it that way.

Or wrap it in a custom processor.

https://community.hortonworks.com/articles/73811/trigger-sonicpi-music-via-apache-nifi.html

avatar
Explorer

What helped me was, first copying the file to the $NIFI_HOME/lib folder then giving the full path of the jar file in the ExecuteStreamCommand processor. So the config looked like "-jar; /opt/nifi-1.7.1/lib/mycode.jar". Couple things to ensure is that the jar is owned by the same user that NiFi is running as and the jar could be located anywhere as long as you give full path you should be fine.