cancel
Showing results for 
Search instead for 
Did you mean: 

CAP Java - Destination - Proxy Configuration

Moritz__
Explorer
0 Kudos

Hello Community,

we are developing a Java CAP application on the BTP and need to access data from an on-premise system.

The cloud connector is configured and the destination created in the cockpit.

We are able to use curl in the Business Application Studio terminal and use the destination.

We followed the documentation to access remote services in Java CAP and create a HTTP client.

import com.sap.cloud.sdk.cloudplatform.connectivity.Destination;
import com.sap.cloud.sdk.cloudplatform.connectivity.DestinationAccessor;
import com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor;
import org.apache.http.client.HttpClient;

Destination destination = DestinationAccessor.getDestination("toKbvStage");
HttpClient client = HttpClientAccessor.getHttpClient(destination);

On the BAS we export some configuration and are then able to use the HTTP client.

export destinations='[ { "type": "HTTP", "name": "toKbvStage", "url": "http://toKbvStage.dest", "ProxyHost": "localhost", "ProxyPort": 8887 } ]'

 In the mta.yaml we bind the destination service to our service. In the log file we receive the following error:

Unable to create an HttpClient from the provided destination. The destination is supposed to target an on-premise system but lacks the correct proxy configuration. Please check the application logs for further details.

My interpretation of the error is, that the destination is found, but something on the destination configuration is missing. Does anybody know, how to solve this? Am I missing any additional configuration?

Accepted Solutions (1)

Accepted Solutions (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert

Hi @Moritz__,

1) Try using the following excerpt from CAP's documentation:

HttpDestination destination = DestinationAccessor.getDestination("toKbvStage").asHttp();
HttpClient httpClient = HttpClientAccessor.getHttpClient(destination);

2) Make sure your application has successfully retrieved an actual destination from BTP. I heavily make use of the log facility to write log entries (instead of a full debug session - which is possible by the way).

public class MyClass {
	private Logger logger = LoggerFactory.getLogger(MyClass.class);
...
logger.info("----> inbound request started");
logger.debug("----> started");
...
}

TIP1: Don't forget to set your application's log level to debug if you are using the 'debug' method. 

TIP2: Download the full trace files from the cockpit and analyze it from a local tool (like notepad++). The viewer is good for very simple tasks, but it fails to give you a good view of stack traces which makes it difficult to see 'caused by...' errors. You could also use CF CLI to download the full app logs if you find that more useful. 

3) If you aren't retrieving a destination, that means the program is looking at the destination instance you've bound your service to, instead of the sub-account level destination. If so, then add the destination on the service instance instead of the sub-account's.

4) Debugging is not too hard to accomplish on Cloud Foundry:

https://community.sap.com/t5/technology-blogs-by-sap/max-s-adventure-in-sap-cloud-platform-debug-you...

https://learning.sap.com/learning-journeys/develop-advanced-extensions-with-sap-cloud-sdk/exercise-d...

Hope this helps.

Best regards,
Ivan

Moritz__
Explorer
0 Kudos

Hello @Ivan-Mirisola,

thank you for your response. I heavily added logs to the code and even used a normal destination and a http destination.

I accessed the properties of the destination and they are set, as they are configured in the cockpit. The httpDestination has a proxy configuration object, which is not defined as the error message suggests.

        log.info("The time is now {}", System.currentTimeMillis());

        Destination destination = DestinationAccessor.getDestination("toKbvStage");
        destination.getPropertyNames().forEach(x -> {
            try {
                Object value = destination.get(x).get();
                log.info("Destination Property: " + x + " - " + value.toString());
            } catch (NoSuchElementException e) {
                log.info("Destination Property: " + x + " - null");
            }
        });
        HttpDestination httpDestination = destination.asHttp();
        httpDestination.getPropertyNames().forEach(x -> {
            try {
                Object value = destination.get(x).get();
                log.info("Destination Property: " + x + " - " + value.toString());
            } catch (NoSuchElementException e) {
                log.info("Destination Property: " + x + " - null");
            }
        });
        try {
            ProxyConfiguration proxyConfiguration = httpDestination.getProxyConfiguration().get();
            String uri = proxyConfiguration.getUri().toString();
            log.info("proxyConfiguration: uri " + uri);
        } catch (NoSuchElementException e) {
            log.info("proxyConfiguration: null");

        }
        HttpClient client = null;
        try {
            client = HttpClientAccessor.getHttpClient(destination);
            log.info("HttpClient created from destination");
        } catch (Exception e) {
            log.info("HttpClient cannot be created from destination");
            e.printStackTrace();
        }
        try {
            client = HttpClientAccessor.getHttpClient(httpDestination);
            log.info("HttpClient created from httpDestination");
        } catch (Exception e) {
            log.info("HttpClient cannot be created from httpDestination");
            e.printStackTrace();
        }
        if (client == null) {
            log.info("HttpClient not initialized - exit");
            return;
        }
        log.info("HttpClient initialized - continue with request");

 The logs:

2024-04-09T08:33:00.605+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.605Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : The time is now 1712651580605
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Authentication - BasicAuthentication
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.authTokens - [DestinationServiceV1Response.DestinationAuthToken(type=Basic, value=<removed>, error=null, expiresIn=null, httpHeaderSuggestion=Header(name=Authorization, value=Basic <removed>), expiryTimestamp=null)]
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.propertiesForChangeDetection - [Name, Type, URL, Authentication, ProxyType, HTML5.DynamicDestination, User, WebIDEEnabled, Password, WebIDEUsage]
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.tenantId -
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: HTML5.DynamicDestination - true
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Name - toKbvStage
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Password - <removed>
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: ProxyType - OnPremise
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Type - HTTP
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: URL - http://kbv-stage.<removed>:443
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: User - <removed>
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: WebIDEEnabled - true
2024-04-09T08:33:00.698+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: WebIDEUsage - odata_abap, dev_abap, odata_gen
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Authentication - BasicAuthentication
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.authTokens - [DestinationServiceV1Response.DestinationAuthToken(type=Basic, value=<removed>, error=null, expiresIn=null, httpHeaderSuggestion=Header(name=Authorization, value=Basic <removed>=), expiryTimestamp=null)]
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.propertiesForChangeDetection - [Name, Type, URL, Authentication, ProxyType, HTML5.DynamicDestination, User, WebIDEEnabled, Password, WebIDEUsage]
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.698Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: cloudsdk.tenantId -
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: HTML5.DynamicDestination - true
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Name - toKbvStage
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Password - <removed>
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: ProxyType - OnPremise
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: Type - HTTP
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: URL - http://kbv-stage.<removed>:443
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: User - <removed>
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: WebIDEEnabled - true
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : Destination Property: WebIDEUsage - odata_abap, dev_abap, odata_gen
2024-04-09T08:33:00.699+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.699Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : proxyConfiguration: null
2024-04-09T08:33:00.700+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.700Z  INFO 9 --- [   scheduling-1] ContainerTrustManagerFactory$PKIXFactory : Adding System Trust Manager
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.701Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : HttpClient cannot be created from destination
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException: com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Unable to create an HttpClient from the provided destination. The destination is supposed to target an on-premise system but lacks the correct proxy configuration. Please check the application logs for further details.
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetOrCreateHttpClient(AbstractHttpClientCache.java:102)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetHttpClient(AbstractHttpClientCache.java:46)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor.tryGetHttpClient(HttpClientAccessor.java:196)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor.getHttpClient(HttpClientAccessor.java:171)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at customer.coco.services.systems.kbv.KbvDatapoolService.reportCurrentTime(KbvDatapoolService.java:61)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.runInternal(ScheduledMethodRunnable.java:130)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.lambda$run$2(ScheduledMethodRunnable.java:124)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at io.micrometer.observation.Observation.observe(Observation.java:499)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:124)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
2024-04-09T08:33:00.701+0000 [APP/PROC/WEB/0] STDERR at java.base/java.lang.Thread.run(Unknown Source)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR Caused by: com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Unable to create an HttpClient from the provided destination. The destination is supposed to target an on-premise system but lacks the correct proxy configuration. Please check the application logs for further details.
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientWrapper.<init>(HttpClientWrapper.java:89)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientFactory.createHttpClient(AbstractHttpClientFactory.java:47)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.lambda$tryGetOrCreateHttpClient$0(AbstractHttpClientCache.java:73)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.lambda$tryGetOrCreateHttpClient$3(AbstractHttpClientCache.java:92)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2688)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2686)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2669)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetOrCreateHttpClient(AbstractHttpClientCache.java:92)
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDERR ... 19 more
2024-04-09T08:33:00.702+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.702Z  INFO 9 --- [   scheduling-1] ContainerTrustManagerFactory$PKIXFactory : Adding System Trust Manager
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.703Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : HttpClient cannot be created from httpDestination
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException: com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Unable to create an HttpClient from the provided destination. The destination is supposed to target an on-premise system but lacks the correct proxy configuration. Please check the application logs for further details.
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetOrCreateHttpClient(AbstractHttpClientCache.java:102)
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetHttpClient(AbstractHttpClientCache.java:46)
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor.tryGetHttpClient(HttpClientAccessor.java:196)
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor.getHttpClient(HttpClientAccessor.java:171)
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor.getHttpClient(HttpClientAccessor.java:149)
2024-04-09T08:33:00.703+0000 [APP/PROC/WEB/0] STDERR at customer.coco.services.systems.kbv.KbvDatapoolService.reportCurrentTime(KbvDatapoolService.java:68)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.runInternal(ScheduledMethodRunnable.java:130)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.lambda$run$2(ScheduledMethodRunnable.java:124)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at io.micrometer.observation.Observation.observe(Observation.java:499)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:124)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.lang.Thread.run(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR Caused by: com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Unable to create an HttpClient from the provided destination. The destination is supposed to target an on-premise system but lacks the correct proxy configuration. Please check the application logs for further details.
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientWrapper.<init>(HttpClientWrapper.java:89)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientFactory.createHttpClient(AbstractHttpClientFactory.java:47)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.lambda$tryGetOrCreateHttpClient$0(AbstractHttpClientCache.java:73)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.lambda$tryGetOrCreateHttpClient$3(AbstractHttpClientCache.java:92)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2688)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2686)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2669)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR at com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache.tryGetOrCreateHttpClient(AbstractHttpClientCache.java:92)
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDERR ... 20 more
2024-04-09T08:33:00.704+0000 [APP/PROC/WEB/0] STDOUT 2024-04-09T08:33:00.704Z  INFO 9 --- [   scheduling-1] c.c.s.systems.kbv.KbvDatapoolService     : HttpClient not initialized - exit

 I understand, that the BAS is using some kind of proxy to make requests via curl or other tools possible. In BAS I can run curl against this.

kbv-curl.png

The destination is configured as followed in the cockpit:kbv-dest.png

The target application is only available on the intranet, so the proxy type must be OnPremise. We tried changing it to internet and then the http client can be created, but of course the destination is not working anymore.
Is there anything else, where we could configure this missing proxy? Is it something on the cloud connector? We just have sub-account access.

Thank you and best regards,

Moritz

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @Moritz__,

1) Do you have an instance of "Connectivity Service' created and bound to your application.

Documentation states that this is mandatory in order for the proxy type to be determined properly:
https://sap.github.io/cloud-sdk/docs/java/features/connectivity/on-premise#cloud-foundry-to-on-premi...

2) Do you have the following on your application class as described by the documentation below:

https://sap.github.io/cloud-sdk/docs/java/getting-started#framework-integration

 

@ComponentScan({"com.sap.cloud.sdk", <your.own.package>})
@ServletComponentScan({"com.sap.cloud.sdk", <your.own.package>})

 

3) Did you configure your Cloud Connector with a 'Location'?

Can you check that it is really connecting to the correct sub-account on the cockpit?
If you open your cockpit under menu Connectivity, there is a 'Cloud Connectors' menu.
Once opened, you will be able to see which Cloud Connectors are active and what is their configuration: like ACL and Location IDs.

Usually, you don't set up a Location ID for a Cloud Connector, unless you have multiple connections into the same sub-account.
Which means that a Destination with the same name can connect to different backend systems, simply by modifying the Location ID during the connection.

If location is not something you would be using for multiple CC's, then I would remove the location id entirely from the CC setup and try again.

Whenever an external call has to be made, there are two options for your application:

1) Connect to the outside world via an internal http proxy: this is done automatically by the application when it goes to the internet

2) Forward the request to a Cloud Connector: this is done for all destinations that are marked as 'On-Premise'. Which means it shouldn't use any proxy configuration.
I guess that the error for the HTTPClient is misleading. It is probably being thrown at the moment it tries to open an http socket with the resource, but since it isn't found at your sub-account, it assumes that you don't have any means (proxy) to reach the resource. This might be happening because the application is not finding any CC available that can handle the request - probably due to the 'location' being set on the CC. Chances are that it is finding a connected CC, but it is not the one that it is supposed to be used for this connection. 

If after reviewing bindings and your CC setup, this is still not working, it might be some issue with BTP or Cloud SDK. Then I would open a ticket at SAP Support channels for further investigation.

BTW: Did you know you can connect to an OData end-point using Cloud SDK the following way (instead of retrieving an http client yourself):

https://developers.sap.com/tutorials/s4sdk-odata-service-cloud-foundry.html#fa798bc1-f35a-4dc5-862e-...

Best regards,
Ivan

Moritz__
Explorer
0 Kudos
Hello @Ivan-Mirisola, thank you! We were missing the binding for the connectivity service. Now the destination can be used as expected. The proxy configuration is set as well and points to some connectivityproxy.internal.* url. Best regards, Moritz

Answers (0)