the docker images built using the build-image goal use JDK 16 in the container instead of the JDK specified in the pom
Spring boot version : 2.4.3
Comment From: wilkinsona
That shouldn't be the case. The buildpack should use the latest LTS version by default. At the time of writing that's Java 11. This is controlled by the BP_JVM_VERSION
environment variable.
Here's an excerpt from ./mvnw spring-boot:build-image
showing the contribution of the JVM to the image:
[INFO] [creator] Paketo BellSoft Liberica Buildpack 8.1.2
[INFO] [creator] https://github.com/paketo-buildpacks/bellsoft-liberica
[INFO] [creator] Build Configuration:
[INFO] [creator] $BP_JVM_VERSION 11.* the Java version
[INFO] [creator] Launch Configuration:
[INFO] [creator] $BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation
[INFO] [creator] $BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation
[INFO] [creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation
[INFO] [creator] $JAVA_TOOL_OPTIONS the JVM launch flags
[INFO] [creator] BellSoft Liberica JRE 11.0.11: Contributing to layer
[INFO] [creator] Downloading from https://github.com/bell-sw/Liberica/releases/download/11.0.11+9/bellsoft-jre11.0.11+9-linux-amd64.tar.gz
[INFO] [creator] Verifying checksum
[INFO] [creator] Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
[INFO] [creator] Adding 129 container CA certificates to JVM truststore
[INFO] [creator] Writing env.launch/BPI_APPLICATION_PATH.default
[INFO] [creator] Writing env.launch/BPI_JVM_CACERTS.default
[INFO] [creator] Writing env.launch/BPI_JVM_CLASS_COUNT.default
[INFO] [creator] Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
[INFO] [creator] Writing env.launch/JAVA_HOME.default
[INFO] [creator] Writing env.launch/MALLOC_ARENA_MAX.default
[INFO] [creator] Launch Helper: Contributing to layer
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/active-processor-count
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
[INFO] [creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
[INFO] [creator] JVMKill Agent 1.16.0: Contributing to layer
[INFO] [creator] Downloading from https://github.com/cloudfoundry/jvmkill/releases/download/v1.16.0.RELEASE/jvmkill-1.16.0-RELEASE.so
[INFO] [creator] Verifying checksum
[INFO] [creator] Copying to /layers/paketo-buildpacks_bellsoft-liberica/jvmkill
[INFO] [creator] Writing env.launch/JAVA_TOOL_OPTIONS.append
[INFO] [creator] Writing env.launch/JAVA_TOOL_OPTIONS.delim
[INFO] [creator] Java Security Properties: Contributing to layer
[INFO] [creator] Writing env.launch/JAVA_SECURITY_PROPERTIES.default
[INFO] [creator] Writing env.launch/JAVA_TOOL_OPTIONS.append
[INFO] [creator] Writing env.launch/JAVA_TOOL_OPTIONS.delim
The BP_JVM_VERSION
has the expected default value of 11.*
and this has resulted in Java 11.0.11+9
being contributed to the image.
Starting the resulting image confirms that Java 11.0.11
is being used:
docker run docker.io/library/gh-27114:0.0.1-SNAPSHOT
Setting Active Processor Count to 8
Calculating JVM memory based on 622912K available memory
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx242159K -XX:MaxMetaspaceSize=73552K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 622912K, Thread Count: 50, Loaded Class Count: 10572, Headroom: 0%)
Adding 129 container CA certificates to JVM truststore
Spring Cloud Bindings Enabled
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -agentpath:/layers/paketo-buildpacks_bellsoft-liberica/jvmkill/jvmkill-1.16.0-RELEASE.so=printHeapHistogram=1 -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx242159K -XX:MaxMetaspaceSize=73552K -XX:ReservedCodeCacheSize=240M -Xss1M -Dorg.springframework.cloud.bindings.boot.enable=true
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2021-06-28 16:09:10.455 INFO 1 --- [ main] com.example.gh27114.Gh27114Application : Starting Gh27114Application v0.0.1-SNAPSHOT using Java 11.0.11 on b16321091c32 with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
2021-06-28 16:09:10.458 INFO 1 --- [ main] com.example.gh27114.Gh27114Application : No active profile set, falling back to default profiles: default
2021-06-28 16:09:10.855 INFO 1 --- [ main] com.example.gh27114.Gh27114Application : Started Gh27114Application in 0.806 seconds (JVM running for 1.23)
If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: saad14092
Hello and sorry for the late reply. You are absolutely right and there was a properties file where the value 16. is passed to the BP_JVM_VERSION. But the other problem seems to be that the image construction fails if we specify 15. as the BP_JVM_VERSION.
Does the buildpack only support LTS versions ?
Thank you
Comment From: wilkinsona
Thanks for letting us know.
They support LTS versions and the latest non-LTS. This means that the release of Java 16 resulted in support for Java 16 replacing support for Java 15. You can learn more about the specific versions here.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.