Unable to access jarfile remoting.jar

I am have a Jenkins setup, where Controller (linux) is connected to slave (windows) via ssh using username/password authentication. I am whenever I try to launch the agent I get Error: Unable to access jarfile remoting.jar. I have tried modifying the file and folder permissions, but that didn’t seen to fix the issue. What is causing jenkins to not be able to access or execute the jarfile?

“Remote Root Directory” is set to D:\Jenkins1114, Default Shell is cmd.exe, Java version on slave is 16.0.1, Java version on Controller is 11.0.13

Relevant logs:

[12/28/21 15:37:40] [SSH] Starting agent process: cd "D:\Jenkins1114" && java  -jar remoting.jar -workDir D:\Jenkins1114 -jar-cache D:\Jenkins1114/remoting/jarCache
Error: Unable to access jarfile remoting.jar
Agent JVM has terminated. Exit code=1
[12/28/21 15:37:41] Launch failed - cleaning up connection
[12/28/21 15:37:41] [SSH] Connection closed.

s/slave/agent/

I don’t think java 16 us supported yet, but I don’t think that would cause the problem

My guess is that the jar file isn’t a jar file. Can you open it in an editor to confirm its not html, or rename it to .zip and see if explorer can read the contents?

Sorry for the very late reply. The file can be read by explorer when renamed to .zip. I will try downgrading to java 11 later today, and will update this thread if it works.

In all the results of googling, 4 Useful Methods to Fix the “Unable to Access Jarfile” Error - MiniTool might be the only useful one (I found it amusing that I found your StackOverflow issue too).

So its possible that your %JAVA_HOME% isn’t set right. or The filesystem its trying to run on isn’t happy with java (network mount? tmp? some windows security? etc).

Otherwise I don’t really know sorry.

Thank you for your help!

UPDATE: I have figured out that it must have something to do with the cmd.exe shell, because it runs fine on PowerShell. I will try to figure out a workaround for this and will update this thread later today.

The error is in the troubleshooting guide ssh-slaves-plugin/TROUBLESHOOTING.md at 22bdd5d2b9f429b099400390330bd1801e5467c5 · jenkinsci/ssh-slaves-plugin · GitHub

Cd on windows in CMD.exe changes the path for the drive but do es not change the drive.

So cd d:\foo still leaves you in C:\somewhere. To change the current drive you also need to cd d:. (note the absence of a path.

So by using -jar renoting.jar you are telling java to load tempting fro. The current drive and path which will likely be somewhere in C:\

Either add a call tomorrow cd to change the drive or pass the full path to remoting.jar to java.

Thank you so much, this worked!