You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I have a simplified action which sets up Java inside of a container. Depending on the container used, I get an error because it fails to run the the installed Java executable, even though it seems to exist. The Java version doesn't seem to matter.
Task version:
v4
Platform:
Ubuntu
macOS
Windows
Runner type:
Hosted
Self-hosted
Repro steps:
Here's a barebones example of the steps in the GitHub action, where test-docker fails and test-ubuntu works.
...
jobs:
test-docker:
runs-on: ubuntu-latestcontainer: docker:clisteps:
- name: Set up JDKuses: actions/setup-java@v4with:
distribution: temurinjava-version: 11
- name: Execute Javarun: | which java type java echo $JAVA_HOME echo $PATH java --helptest-ubuntu:
runs-on: ubuntu-latestcontainer: ubuntu:lateststeps:
- name: Install docker and docker-composerun: | apt -y update apt -y install sudo curl curl -fsSL https://get.docker.com -o get-docker.sh sudo sh ./get-docker.sh apt-get install docker-compose-plugin
- name: Set up JDKuses: actions/setup-java@v4with:
distribution: temurinjava-version: 11
- name: Execute Javarun: | which java type java echo $JAVA_HOME echo $PATH java --help
Expected behavior:
I expect both jobs to successfully install the java executable (which they seem to do) and be able to execute it.
Actual behavior:
The test-docker job seems to install the java library properly, but doesn't seem to be able to execute it. On the other hand, the test-ubuntu job installs the java library properly and is able to run the java executable as expected. In both cases, the java lib seems to exists on disk, but the job using the docker:cli image as its container can't find the java executable. Below is an excerpt of the output of the Execute Java step of each job.
test-docker
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin/java
java is /__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin/java
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/__w/_temp/24f7e9c6-9173-452f-b7b0-833ce68b877a.sh: line 5: /__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin/java: not found
test-ubuntu
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin/java
java is /__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin/java
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64
/__t/Java_Temurin-Hotspot_jdk/11.0.24-8/x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Usage: java [options] <mainclass> [args...]
(to execute a class)
...
The text was updated successfully, but these errors were encountered:
Having kind of the same issue here with my project. Mockito cannot find the java executable. I worked around it via pinning the ubuntu version to 24.04. With ubuntu-latest I get:
Caused by: java.lang.reflect.InvocationTargetException
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:103)
... 10 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker.
It appears as if your JDK does not supply a working agent attachment mechanism.
Java : 21
JVM vendor name : Eclipse Adoptium
JVM vendor version : 21.0.4+7-LTS
JVM name : OpenJDK 64-Bit Server VM
JVM version : 21.0.4+7-LTS
JVM info : mixed mode, sharing
OS name : Windows NT
OS version : 6.5.0-1025-azure
Hi @abbasyadollahi , This issue can be resolved by adding an extra step in the job. Following are the steps that you need to add to make the job work. -
name:Install Java
run: |
apk update && \
apk upgrade
apk add openjdk11=11.0.24_p8-r0
To make the job run successfully, we need to install java in the container using the docker's apline package manager to make to get java executable detected.
Please refer to the attached snip.
Description:
I have a simplified action which sets up Java inside of a container. Depending on the container used, I get an error because it fails to run the the installed Java executable, even though it seems to exist. The Java version doesn't seem to matter.
Task version:
v4
Platform:
Runner type:
Repro steps:
Here's a barebones example of the steps in the GitHub action, where
test-docker
fails andtest-ubuntu
works.Expected behavior:
I expect both jobs to successfully install the
java
executable (which they seem to do) and be able to execute it.Actual behavior:
The
test-docker
job seems to install thejava
library properly, but doesn't seem to be able to execute it. On the other hand, thetest-ubuntu
job installs thejava
library properly and is able to run thejava
executable as expected. In both cases, thejava
lib seems to exists on disk, but the job using thedocker:cli
image as its container can't find thejava
executable. Below is an excerpt of the output of theExecute Java
step of each job.test-docker
test-ubuntu
The text was updated successfully, but these errors were encountered: