-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the bug
With the new Go-based Java Buildpack, the location of the JRE has changed:
for example, from /home/vcap/app/.java-buildpack/open_jdk_jre to the new location /home/vcap/deps/0/jre/jre-17.0.15/.
There are applications that invoke Java via a hardcoded relative path inside the droplet: .java-buildpack/open_jdk_jre/bin/java so those hardcoded paths no longer exist, which breaks apps and CF tasks that rely on that path. For example, an app used to execute CF Task to execute e.g. the DB schema (so the java is currently being invoked via the full path .java-buildpack/open_jdk_jre/bin/java). Or usages like JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR
The new Go-based buildpack has a way to introduce $JAVA_HOME which will do the job but only for new apps (the existing apps pointing to /home/vcap/app/.java-buildpack/open_jdk_jre will fail).
Reproduction steps
- Use an app/script that calls Java using the relative path inside the droplet, e.g.:
.java-buildpack/open_jdk_jre/bin/java -Xms123M org.springframework.boot.loader.launch.JarLauncher - Stage the app using the current or the Go-migration branch of the buildpack.
- Run the app or run a CF task that invokes the hardcoded path.
- Observe that the app fails with
No such file or directory
Expected behavior
Existing apps/CF Tasks could continue to run without modification, even if the buildpack internal JRE layout changes.
Suggested solution
Introduce compatibility shims during staging:
export JAVA_HOME=<the-new-java-location> (available in /profile.d/0_java.sh)
mkdir -p /home/vcap/app/.java-buildpack
ln -s $JAVA_HOME /home/vcap/app/.java-buildpack/open_jdk_jre
ln -s $JAVA_HOME /home/vcap/app/.java-buildpack/sap_machine_jre
- This preserves
.java-buildpack/open_jdk_jreand.java-buildpack/sap_machine_jreas a symlink to the actual JRE location. $JAVA_HOMEpoints to the canonical new location.- Apps with hard-coded paths will continue working.