cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Upgrading sap_java_buildpack to sap_java_buildpack_jakarta

MohanrajV
Discoverer
0 Kudos
241
  • SAP Managed Tags

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

MohanrajV_8-1744121983888.png

 

And changed in buildpack specified in mta.yaml file to sap_java_buildpack_jakarta

MohanrajV_7-1744121886451.png

 

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

MohanrajV_2-1744121397872.png

MohanrajV_6-1744121821372.png

 

if I add and deploy also its giving same error

MohanrajV_5-1744121711853.png

This my pom.xml file

MohanrajV_9-1744122072450.png

 

 

 

 

 
View Entire Topic
Anjali_Pathak
Associate
Associate
0 Kudos

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

aykut_kafali
Newcomer
0 Kudos

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.+ } }'



MohanrajV
Discoverer
0 Kudos
Thanks, We have to specify this two below env variables under the properties tag in the mta.yaml file  properties: JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']" JBP_CONFIG_SAP_MACHINE_JRE: '{ version: 21.+ }'
Ask a Question