Answers: <p>The <em>EnvInject</em> plugin is basically attempting to load the build environment which uses configuration of JDK tools in Jenkins which fails during reinstallation of Java JDK library on the Windows slave (as per given configuration). </p>
  
  <p>This JDK configuration can be found in <em>Global Tool Configuration</em> (at <code>/configureTools</code>) for the given JDK profile which was selected in that job configuration. The installation process failed to reinstall <em>Java JDK</em> due to running Java process in the background (such as <code>java -jar slave.jar</code>) which was using these <em>DLL</em> files.<br>
  So it sounds like it's not possible to reinstall the same Java JDK files which are used to run the Jenkins slave process. </p>
  
  <p>The solution was to disable <em>Install automatically</em> option in <em>Global Tool Configuration</em>, as Java JDK was already installed on that slave.</p>
  
  <p><a href="https://i.sstatic.net/ThdWA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ThdWA.png" alt="Jenkins, Java JDK, Install automatically option"></a></p>
  
  <p><sup>Related: <a href="https://issues.jenkins-ci.org/browse/JENKINS-46989" rel="nofollow noreferrer">JENKINS-46989 - EnvInjectException: remote file operation failed</a>.</sup></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-04-09T10:02:42.760Z
Answers: No working for me :(
Answers: Narendra Chandratre
Answers: CC BY-SA 3.0
Answers: 2017-09-26T19:01:19.823Z
Answers: 2017-09-27T07:57:33.927Z
Answers: 2017-09-27T07:57:33.927Z
Answers: kenorb
Body: <p>I've the following error in Jenkins console when running job which uses Windows slave:</p>
  
  <pre><code>Started by user 
    [EnvInject] - Loading node environment variables.
   ERROR: SEVERE ERROR occurs
   org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at org.jenkinsci.plugins.envinject.util.RunHelper.getBuildVariables(RunHelper.java:137)
   at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:236)
   at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:50)
   at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:534)
   at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:454)
   at hudson.model.Run.execute(Run.java:1737)
  ...
   Caused by: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at hudson.FilePath.act(FilePath.java:994)
   at hudson.FilePath.act(FilePath.java:976)
  ...
   Caused by: java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at hudson.Util.deleteFile(Util.java:250)
   at hudson.FilePath.deleteRecursive(FilePath.java:1211)
  ...
  Caused by: java.nio.file.AccessDeniedException: C:\Program Files\Java\jre1.8.0_91\bin\awt.dll
   at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
  </code></pre>
  
  <p>which stops the job at the very start.</p>
  
  <p>I've no idea why <em>EnvInject</em> plugin would want to remove some Java files (such as <code>awt.dll</code>).</p>
  
  <p>Any idea how to solve this problem?</p>
  
Tags: <jenkins><java>
Title: org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: remote file operation failed
UserDisplayName: kenorb
ThreadText: # org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: remote file operation failed
  
  (Asked by: username_0 on 2017-09-26)
  
  I've the following error in Jenkins console when running job which uses Windows slave:
  
  ```
  Started by user 
    [EnvInject] - Loading node environment variables.
   ERROR: SEVERE ERROR occurs
   org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at org.jenkinsci.plugins.envinject.util.RunHelper.getBuildVariables(RunHelper.java:137)
   at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:236)
   at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:50)
   at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:534)
   at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:454)
   at hudson.model.Run.execute(Run.java:1737)
  ...
   Caused by: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at hudson.FilePath.act(FilePath.java:994)
   at hudson.FilePath.act(FilePath.java:976)
  ...
   Caused by: java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
   at hudson.Util.deleteFile(Util.java:250)
   at hudson.FilePath.deleteRecursive(FilePath.java:1211)
  ...
  Caused by: java.nio.file.AccessDeniedException: C:\Program Files\Java\jre1.8.0_91\bin\awt.dll
   at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
  
  ```
  
  which stops the job at the very start.
  
  I've no idea why *EnvInject* plugin would want to remove some Java files (such as `awt.dll`).
  
  Any idea how to solve this problem?
  
  **Tags:** jenkins, java
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-09-26. Score: 5 | Accepted answer
  
  The *EnvInject* plugin is basically attempting to load the build environment which uses configuration of JDK tools in Jenkins which fails during reinstallation of Java JDK library on the Windows slave (as per given configuration).
  
  This JDK configuration can be found in *Global Tool Configuration* (at `/configureTools`) for the given JDK profile which was selected in that job configuration. The installation process failed to reinstall *Java JDK* due to running Java process in the background (such as `java -jar slave.jar`) which was using these *DLL* files.  
  So it sounds like it's not possible to reinstall the same Java JDK files which are used to run the Jenkins slave process.
  
  The solution was to disable *Install automatically* option in *Global Tool Configuration*, as Java JDK was already installed on that slave.
  
  [![Jenkins, Java JDK, Install automatically option](https://i.sstatic.net/ThdWA.png)](https://i.sstatic.net/ThdWA.png)
  
  Related: [JENKINS-46989 - EnvInjectException: remote file operation failed](https://issues.jenkins-ci.org/browse/JENKINS-46989).
  
  > **Comments:**
  > **username_1**: No working for me :(  
  
  ---
  
  