on 06-17-2020 11:01 AM
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
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 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
I suggest to report an incident on BC-MID-CON-JCO as described on the JCo product page.
User | Count |
---|---|
87 | |
11 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.