Search code examples
javaubuntuant

Can't Launch Exec Task from Ant


I am trying to execute a separate function from an ant script and keep getting

Caused by: java.io.IOException: error=13, Permission denied
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
        ... 58 more

I eventually want to call Docker but to simplify it I am simply trying to call echo.

My exec block looks like this

 <exec failonerror="true" vmlauncher="false" executable="/usr/bin/echo">
      <arg value="testing" />
  </exec>

I have tried with vmlauncher true and false and get variations on the same error.

Outside of ant I can run echo no problem, but here is what ls -al says about it -rwxr-xr-x 1 root root 35120 Feb 7 2022 echo

I'm testing this on an Ubuntu WSL 2 container, but have had similar issues on an Amazon Linux image.


Solution

  • I finally figured it out today. I'm running on a custom jre and had only enabled run permission on the bin directory. There must be something in a different subdirectory that is required, because if I give execute permission on the whole jre it works properly.