cancel
Showing results for 
Search instead for 
Did you mean: 

Exception in execution of BAPI using SAP Cloud SDK 3.18

0 Kudos

This is a follow up to my previous question posted on https://answers.sap.com/questions/13057648/exception-in-execution-of-bapi-using-sap-cloud-sdk.html. I am trying to call BAPI using SAP Cloud SDK version 3.18 using Java.

I have created a Spring Boot application for doing this. Below is the code which I am using:

@RequestMapping(value="/costCenters", method = RequestMethod.GET, produces ="application/json")
  private CostCenter getCostCenterDetails() throws RequestExecutionException{

  final Destination destination =DestinationAccessor.getDestination("ErpQueryEndpoint");
    final BapiRequestResult resultCostCenterDetail = new BapiRequest("BAPI_COSTCENTER_GETLIST1")
            .withExporting("CONTROLLINGAREA", "BAPI0012_1-CO_AREA", "0001")
            //.withExporting("COSTCENTER", "BAPI0012_1-COSTCENTER", chosenCostCenter.getId())
            .withImportingFields("COSTCENTERDETAIL", "BAPI0012_CCOUTPUTLIST").end()
            .withTableAsReturn("BAPIRET2")
            .execute(destination);
    return resultCostCenterDetail.get("COSTCENTERDETAIL").getAsObject().as(CostCenter.class);
  }

I have created RFC destination in CF and Cloud Connector. However When I am trying to execute it I am getting below error:

Caused by: com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: org.springframework.web.util.NestedServletException:Handler dispatch failed;nestedexceptionis java.lang.NoClassDefFoundError: com/sap/conn/jco/JCoException
	at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:325)~[cloudplatform-core-3.18.0.jar:na]at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)~[servlet-3.18.0.jar:na]

I have tried adding jco dependencies but maven goal fails to execute as these dependencies are no longer available in maven repository. Could you please help me in resolving this.

Regards,

Kamalpreet

artemkovalov
Employee
Employee
0 Kudos

Adding to marco.dahms answer, I'd recommend updating the the SDK to ver. 3.21 or above.

View Entire Topic
former_member186608
Active Participant
0 Kudos

Please go through the Stackoverflow question and answers, I guess it will shed some light here:
https://stackoverflow.com/questions/61073716/define-scp-destination-for-s4hana-bapi-call-with-cloud-...

Tell me in case if does not solve your problem 🙂

0 Kudos

Hello Marco,

I have gone through the link which you have shared. As per the link Spring boot projects cannot use jco libraries. I have created a new project based on servlets but still I am getting the same error.

Can you please suggest.

former_member186608
Active Participant
0 Kudos

Hello Kamalpreet,

I need more details to help you.

- How did you create the project?

- Are you able to provide us a minimal example of your project, e.g. on Github?

0 Kudos

Hello Marco,

I have created the project using MTA template in SAP Web IDE and added java web application module. I added my bapi execution code which I have given in the question in the generated HelloServlet.java and added sdk dependencies in pom.xml.

All the other things are default. I have added connectivity , xsuaa and destination services as well.

I am deploying this project through web IDE.

As a workaround I have added sapjco3.jar externally in the project and I was able to resolve the classNotFoundException of jco. Now I am getting below error when I am hitting the end point:

com.sap.cloud.sdk.s4hana.connectivity.rfc.exception.RemoteFunctionException: com.sap.conn.jco.JCoException: (106) JCO_ERROR_RESOURCE: Destination onPremBapi does not exist
{ "written_at":"2020-06-19T04:22:24.992Z","written_ts":50463805768082,"component_id":"5602baa5-f274-4685-a568-2ac574a8aa2f","component_name":"3MP3aFt1ENd0j22zpiDemo1-BapiDemo1","DCComponent":"","organization_name":"-","component_type":"application","space_name":"dev","component_instance":"0","organization_id":"-","correlation_id":"-","CSNComponent":"","space_id":"859253dd-78fe-4441-8082-dce0b6369f8d","Application":"3MP3aFt1ENd0j22zpiDemo1-BapiDemo1","container_id":"10.32.1.6","type":"log","logger":"org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[com.company.bapidemo1.BapiDemo1.HelloServlet]","thread":"http-nio-0.0.0.0-3000-exec-1","level":"ERROR","categories":[],"msg":"Servlet.service() for servlet 

onPremBapi is my RFC destination which I have created in cloud foundry and cloud connector. I am not sure why I am getting this. Your help would be appreciated.

Regards,

Kamalpreet

former_member186608
Active Participant
0 Kudos

Can you attach the Maven dependency tree and share a screenshot of your RFC destination?

0 Kudos

Hello Marco,

Please find attached maven dependency tree and destination screen shot from cloud foundry and cloud connector.

Regards,

Kamalpreet

former_member186608
Active Participant
0 Kudos

Thanks, that looks OK so far.

Please provide more insights:

- Do you use the SAP Java Build Pack? Please attach your deployment descriptor, like mta.yaml or manifest.yaml

- Attach the full application log

0 Kudos

Hello Marco,

No, I am not using sap_java_buildpack. I tried to change it through mta.yaml(as web ide does not read manifest.yml), but cloud foundry takes the default build pack which is:

https://devxjavabp-121.cfapps.eu10.hana.ondemand.com/java-buildpack.git

Attached is the mta.yaml file and error logs as required.

Also I tried deploying the app through cloud foundry command line using manifest.yml with sap_java_builpack, But i get memory issues while deploying that. Tried increasing memory utilization but still not able to deploy.

Regards,

Kamalpreet

0 Kudos

Hi Experts,

Can you please help me out to resolve this. I am stuck on this and cannot proceed further.

Regards,

Kamalpreet

former_member186608
Active Participant
0 Kudos

I suggest to report an incident on BC-MID-CON-JCO as described on the JCo product page.