1
votes

I am running a java program from a shell script through Oozie and I get the below error

java: command not found

When I run the shell script from the edge node I do not find any issues and the java class runs without any error and I get the desired output also. However it is the oozie job that fails to run the java command.

All other actions in oozie are executed porperly but when it encounters the java line, it throws the afore said error. I understand that all the nodes in the Hadoop cluster will have Java installed, then why do I get this error? Below is the java command that I have in my shell script

...
...    
java -cp $LOCAL_DIR/libs/integration-tools.jar com.audit.reporting.GenerateExcelReport $LOCAL_DIR/input.txt $LOCAL_DIR/
...

Please provide your thoughts.

2
java: command not found generally indicates that your PATH does not include the location of the java command. Compare echo "$PATH" in this environment to echo "$PATH" in an environment where the JVM can be successfully invoked. - Charles Duffy
...certainly, Java may be installed, but the question is whether the location where it's installed is currently in the PATH for the process at hand. Many operating systems install the JVM in a location like /usr/lib/jvm/java8-jre-bin or such, and daemons may not have that location (whatever the exact relevant/correct location is) in their PATH. - Charles Duffy
By the way -- all-caps names are used for variables with meaning to the operating system or shell, whereas names with at least one lowercase character are reserved for application use, to prevent applications from overwriting meaningful names by mistake. See the relevant POSIX specification at pubs.opengroup.org/onlinepubs/9699919799/basedefs/… - Charles Duffy

2 Answers

0
votes

"Issue Fixed"

I talked with my DevOps later and found that the classpath for Java was not set in few datanodes in the Cluster. This was stopping the shell action to invoke the JVM at those datanodes. After fixing the Classpath, the job ran successfully. All the comments mentioned by @Charles Duffy are valid.

-1
votes

Do you have your integration-tools.jar along with your code jar in hdfs location? Oozie can choose any node to run the java action and it will look for these jar at that location.