0

I goes along the tutorial at https://developers.sap.com/tutorials/s4sdk-odata-service-cloud-foundry.html. I set destinations as described to a running Mockserver on the Internet with no user and password. I'm using the latest version of the 3.xx SDK.

set destinations=[{name: "dest", url: "https://businesspartner-odata-mock-server-timely-lynx.cfapps.eu10.hana.ondemand.com"}]

I have verified the destinations variable and it's look fine. I add the businessServlet as described.

private final ErpHttpDestination destination = DestinationAccessor.getDestination("dest").asHttp().decorate(DefaultErpHttpDestination::new);

I run it local along the tutorial and use a debugger. The error is:

com.sap.cloud.sdk.cloudplatform.exception.CloudPlatformException: Environment variable 'VCAP_SERVICES' is not defined.

I seems the destination Environment Variable is not used. I have two questions:

  1. How can I fix this problem to run the app local against an mockserver with business data? I read the troubleshooting area and try a lot of chances.
  2. It is possible to set this Environment Variable in the application.properties or in another way?

Thanks a lot Peter

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
PeterA
  • 1
  • 1
  • Can you please share the whole stacktrace of the `CloudPlatformException` you received? Oh, and can you also verify that the `destinations` variable is actually set? Depending on your operating system the command might look different. What the SDK does under the hood (at least atm) is using the `Systems.getenv(String)` method to read the `destinations` environment variable. – Christoph Schubert Nov 25 '19 at 13:37
  • The command to set the destinations variable appears correct (tried it myself). But in which sequence and which cmd/powershell/etc. are you running the commands to set variable and start the local TomEE? Since the variable is not set globally, the two must be run in the same shell window. If you are using an IDE like Eclipse/IntelliJ to start the local TomEE then you have to configure the destinations variable in your launch configuration. – Pablo Caceres Nov 27 '19 at 11:52
  • Still, our best guess based on the given information is that the environment variable can, for whatever reason, not be read from your application/the SDK. Can you please provide the exact steps you executed to set the environment variable and then started the application from the same terminal? – Christoph Schubert Dec 02 '19 at 07:41

1 Answers1

1

You should define environmental variable destination if you are running app locally

cf set-env firstapp destinations "[{name: \"ErpQueryEndpoint\", url: \"https://URL\", username: \"USER\", password: \"PASSWORD\"}]"

Read the tutorial

https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/

VCAP_SERVICES variable is not defined on local scenarios. BTW, the tutorial you use is intended for S/4HANA Cloud Foundry instance, not local.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
  • Dear Suncatcher, thanks for your answer. Thats exact the problem, both tutorials give a local deployment option. Thats exact what I do. The deployment to cf works as you describe. My problem is thats a local deployment does not works a describted in the tutorial. best regards Peter – PeterA Nov 24 '19 at 08:24
  • [I don't see](https://imgur.com/tcDqMw5) option for local development in tutorials, only cloud on CF or NEO platform. Update your post and explain in great detail your setup and how do you deploy locally and maybe I will be able to help – Suncatcher Nov 25 '19 at 19:34