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 #:
6 of 6
Last update:
‎09-29-2018 12:13 AM
Updated by:
 
Labels (3)
Comments
Six Stars

Hello,

Great! thanks for this solution Smiley Happy i tested it and it work correctly.

I have a problem about this topic.

In fact, I have two identical environments :

- For the 1 environnement : my job is executed without problem and without create a symbolic link

- For the 2 evironnement : i was obliged to create this symbolic link to avoid this problem.

 

I didn't understand because my two environments are identical.

Thank you in advance for your help Smiley Happy

 

Best Regards

 

 

Employee

Hi @ridha_rjili,

 

  Glad to know that this article helped you in fixing the issue. 

 

  This issue is observed only when there is no symbolic link for /user/bin/java. We are able to isolate the issue to symbolic link after analyzing a working environment. 

 

  If the issue is not observed when the symbolic link is not defined for /user/bin/java, we need to understand your environment. Please feel free to open a Case. We can verify your environment to isolate the issue.

 

Regards,

Karthick

Support Engineer (Big Data, Java)

Talend Support