on 2025 Apr 08 3:30 PM
Hello Friends,
My issue is while trying to upgrade the java build pack from sap_java_buildpack to sap_java_buildpack_jakarta, we are also upgrading our JDK version to 21.
So i changed buildpack specified in manifest.yml file to sap_java_buildpack_jakarta
And changed in buildpack specified in mta.yaml file to sap_java_buildpack_jakarta
After compiling my code with Java 21, I deployed a simple HelloWorld servlet to Cloud Foundry. However, upon executing the endpoint, I received a "not found" error. I subsequently reviewed the subaccount-level logs for further insights.
"xxxx/Test has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 (unable to load class [xxxx.test.Test])","stacktrace":["java.lang.UnsupportedClassVersionError: xxxx/test/Test has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 (unable to load class [xxxx.test.Test])"
It clearly giving JRE will accept only version 17 only, but my organization has asked to upgrade to Java 21.
I referred this sap help document for upgrading Java to 21
https://help.sap.com/docs/btp/sap-business-technology-platform/sapmachine
SAP mentioned to add below environment variables into manifest.yaml file
if I add and deploy also its giving same error
This my pom.xml file
Request clarification before answering.
Hi @MohanrajV ,
We recently encountered a similar issue during deployment and identified the root cause.
As the environment has already been specified in your manifest file, please update the buildpack to use the default Java buildpack (java_buildpack). Since the Java version is defined in the environment, it will be correctly recognized and applied during deployment.
For your reference, here is a sample manifest file:
applications:
- name: your-application-name
memory: 1G (change as epr your settings)
disk_quota: 512M (change as per your settings)
path: target/your-application-name.jar
buildpack: java_buildpack
env:
JBP_CONFIG_COMPONENTS: '{jres: ["JavaBuildpack::Jre::SapMachineJRE"]}'
JBP_CONFIG_SAP_MACHINE_JRE: "{ jre: { version: 21.+ }}"
Also, we recommend adding the relevant Java properties directly to your application's pom.xml file.
<properties>
<java.version>21</java.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
Hope this helps!
Wishing you a great day ahead!
Best Regards,
Anjali Pathak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For me this is still not working. I had the same settings already in place but for Java 17 and it works fine but when I try to update to Java 21 with just java_buildpack it also starts using tomcat 9 instead of tomcat 10.
My mta env have these properties in place:
JBP_CONFIG_COMPONENTS: '{jres: ["JavaBuildpack::Jre::SapMachineJRE"]}'
JBP_CONFIG_SAP_MACHINE_JRE: "{ jre: { version: 21.+ }}"
JBP_CONFIG_TOMCAT: '{ tomcat: { version: 10.0.+ } }'
User | Count |
---|---|
24 | |
22 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.