Thursday, June 22, 2017

Addressing 'Caused by: java.lang.RuntimeException: Cannot find System Java Compiler.' in Jenkins

I maintain this blog to keep track of common errors encountered in testing and how to solve them so that they'll be useful to anyone including myself.

So this is another one.

In this current CI environment I work, all the jobs run successfully, but when I added a new job for a TestNG project it complained about JAVA_HOME not being found.

Obviously in the environment where this happened, only JRE is installed and I didn't want to change any settings so that there's a possibility of it affecting other tests and jobs.


 So the solution was to add a JDK specifically for this job.

01) Add JDK configuration in Jenkins global configuration (Jenkins -> Manage Jenkins -> Global tool configuration


Even if that specific JDK version is not in the environment, it's possible to download it automatically and install it. What you have to do is provide valid credential to download the binary.

NOTE : I'm using a rather old version of Jenkins here. So steps can be bit different. Specially from where JDK version can be added.

02) I've already configured the job. So this new JDK option did not show up automatically at job configuration UI. So had to restart Jenkins server

03) Now choose the JDK in Job configuration page.


04) Save the configuration and trigger a job. Now it should pick up the JDK version mentioned above and should no longer throw the initial error.

05) Then I ran into another issue and worth mentioning it here. Jenkins download the JDK version and when it tries to access and install it, that operation fails due to not having enough permission.

Software Deployment failure - The requested operation requires elevation


Turn off UAC in the client computers
To turn off UAC follow the steps below,
  1. Select Control Panel --> User Account
    1. For Windows 7 and Windows 2008 R2,
      1. click User Account Control Settings link.
      2. This opens the User Account Control Settings dialog showing the control level.
      3. Drag and choose the control level to Never Notify and click OK
    2. For Windows Vista and Windows 2008
      1. Click "Turn User Account Settings On or Off link
      2. Uncheck the "Use User Account Control (UAC) to protect your computer" option and click OK
  2. Close the Control Panel dialog.
  3. Restart the computer after disabling the UAC for the changes to take effect.



No comments:

Post a Comment