cloudfoundry / cloudfoundry/java-buildpack
[go-migration] Compatibility issue with existing apps due to JRE relocation in the Go-based Java Buildpack
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 452
- Forks
- 2.5k
- Avg merge
- 14h 57m
- Merged PRs (30d)
- 23
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the buildpack staging flow and the /profile.d/0_java.sh entry point mentioned in the issue, then trace where the new JAVA_HOME is established. Reproduce staging with a hard-coded .java-buildpack/open_jdk_jre/bin/java path and verify that both legacy JRE paths resolve to the canonical location while the new JAVA_HOME remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100