A Job fails with the error "java.io.IOException: Cannot run program "java": error=2, No such file or directory " when a tParallelize component is used in the Job

Symptoms

A Job is designed with multiple subJobs. If a tparallelize component is used and the subJob property Use an independent process to run subJob is selected, the Job fails with the following error.

 

Exception in component tRunJob_3
java.io.IOException: Cannot run program "java": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at bda_prod.bmstgcap_main_initial_0_1.BMSTGCAP_Main_Initial.tRunJob_3Process(BMSTGCAP_Main_Initial.java:4155)
at bda_prod.bmstgcap_main_initial_0_1.BMSTGCAP_Main_Initial$4.run(BMSTGCAP_Main_Initial.java:2043)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 4 more

 

 

Diagnosis

  1. When running the Job without the tparallelize component, the issue is not seen. The issue is also not observed when building the Job from Studio and running it using a script on a runtime server. This proves that the subJob is unable to find java during runtime.
  2. The JAVA_HOME and PATH are configured with the correct Java installed locations. You are able to successfully execute the java -version command on the runtime server.
  3. The following stack trace appears in the Job log, and this helps isolate the issue:

    Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)

    The UNIX process is forking the Java, but the Java file is not available. The Java processBuilder class is used to create operating system processes for this Talend Job. The processBuilder looks for Java in /usr/bin/java on UNIX/Linux, and doesn't use the locations in environment variables like PATH or JAVA_HOME. When executing /usr/bin/java from the runtime server, the Java command failed to execute.

 

Solution

To fix the issue, create a symbolic link for the java executable at /usr/bin/java and run the Job.

 

Article References

https://stackoverflow.com/questions/25080194/ioexception-when-starting-a-process

https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

Version history
Revision #:
5 of 5
Last update:
‎12-15-2017 05:38 PM
Updated by:
 
Labels (2)
Contributors