cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP Java hybrid development in BAS

T1mey
Participant
0 Kudos

Hello CAP experts,

I try to use the destination service in my Business Application Studio.

So we need to connect to a destination to retrieve some data. With nodeJS this was quite easy.

For JAVA (+ cloud skd v5)  we tried the same but it's somehow not working.

So we used the CF tools extension to bind the destination service locally. This creates a .env file in the root of the project.

But after starting the app with mvn cds:watch and triggering the action it throws an exception:

Caused by: com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Could not resolve destination to Destination Service on behalf of TECHNICAL_USER_CURRENT_TENANT.
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.lambda$prepareServiceDestinationComputation$1(DestinationServiceAdapter.java:117) ~[connectivity-destination-service-5.8.0.jar:na]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.lambda$prepareServiceDestinationComputation$2(DestinationServiceAdapter.java:109) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.getConfigurationAsJsonInternal(DestinationServiceAdapter.java:226) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.getConfigurationAsJson(DestinationServiceAdapter.java:211) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationService.retrieveDestination(DestinationService.java:155) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationService.lambda$loadAndParseDestination$0(DestinationService.java:138) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.resilience4j.Resilience4jDecorationStrategy.lambda$decorateCallable$2(Resilience4jDecorationStrategy.java:179) ~[resilience4j-5.8.0.jar:na]
at io.github.resilience4j.bulkhead.Bulkhead.lambda$decorateCallable$5(Bulkhead.java:173) ~[resilience4j-bulkhead-2.2.0.jar:2.2.0]
at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor.call(ThreadContextExecutor.java:297) ~[cloudplatform-core-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor.execute(ThreadContextExecutor.java:240) ~[cloudplatform-core-5.8.0.jar:na]
... 8 common frames omitted
Caused by: com.sap.cloud.sdk.cloudplatform.exception.NoServiceBindingException: Please make sure you have the Destination Service bound to your application.
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.getDestinationServiceBinding(DestinationServiceAdapter.java:249) ~[connectivity-destination-service-5.8.0.jar:na]
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationServiceAdapter.lambda$prepareServiceDestinationComputation$1(DestinationServiceAdapter.java:111) ~[connectivity-destination-service-5.8.0.jar:na]
... 18 common frames omitted

Even the creation of a default-env.json in root is not working as the app now wants authentication (reporting directly 401 before loading the UI).

But as we configured 

cds:
  security:
    mock.users:
     ...

we assumed that this overrides this config.

After deployment to CF it works without any problem and retrieves the destination.

How do we setup this locally ?

Accepted Solutions (1)

Accepted Solutions (1)

T1mey
Participant
0 Kudos

Finally I managed it. So CAP JAVA is taking the file default-env.json from the root of the project.

To test with mocked authentication I deleted the xsuaa object out of the VCAP_SERVICES and I was able to login with configured user and use the destination.

Answers (0)