NoClassDefFoundError while using SAP JCo in maven Sprinboot Application SAP CF

294 Views Asked by At

​I am getting below error while trying to use sapjco3 in my Springboot application. I am deploying my application to SAP Cloud foundry environment packaging as war file with tomee7 TARGET_RUNTIME

java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo : cannot initialize class because prior initialization attempt failed]","level":"ERROR"

while adding the dependency from maven it is packaging the sapjco jar with following name and getting below error

java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path:[/usr/java/packages/lib/amd64, /usr/lib64, /lib64, /lib, /usr/lib] and in system

enter image description here

[https://sap.github.io/cloud-sdk/docs/java/features/bapi-and-rfc/overview]

I have packaged the springboot as war instead of jar to resolve the sapjco dependency

https://sap.github.io/cloud-sdk/docs/java/guides/spring-boot-war-deployment

1

There are 1 best solutions below

0
MatKuhr On

Change the scope of the dependency to provided as described in the documentation. SAP Java buildpack already includes a JCo runtime fitting to the Cloud Foundry environment. (credit to Markus who answered this originally here).

For more information on how to manage dependencies provided by the SAP Java Buildpack please refer to the dedicated guide here.