Closed nbblum closed 3 years ago
Hi @nbblum, I am looking into your issue. Thanks for reaching out to the SAP Cloud SDK support!
I'll come back to you once I have more insights.
@nbblum Can you please share the destination configuration with us? Make a screenshot or export the destination and upload the file here. Also, do you use a protected backend? Does the request which triggers your logic contain a JWT?
The log reveals that the destination requires a user identity to resolve the destination.
Second idea: Since you use a Spring app, do you use these annotations on your application class?
@Emdee89 the link for the annotations does not work The application is protected and a JWT exists. I tried fetching the destination manually via the rest api which works fine. So in general it works. But it would be cleaner to use the sdk.
In general webflux is supported?
@nbblum Pls share the destination configuration with us.
Here is the link for the annotations: https://sap.github.io/cloud-sdk/docs/java/guides/cap-sdk-integration/#enable-the-component-scan-for-sap-cloud-sdk-package
Yes, the annotations are already there
OK thanks. I guess I also need the full application log. You can download it from the BTP cockpit as log file. Can you provide that?
@Emdee89 I attached the log but it's more or less what I posted in the issue. If you like you can contact me internally (I517250) mxp-hcms-data-resolver-2021-05-31 07_49_30.268+0000.txt
Can you print the output of TenantAccessor.getCurrentTenant()
and PrincipalAccessor.getCurrentPrincipal()
to the log? Which values are returned? Are you sure that the incoming request contains a JWT from which the SDK can extract a tenant and a principal?
TenantAccessor.getCurrentTenant()
ScpCfTenant(super=DefaultTenant(tenantId=23823d04-1ea5-425a-9840-c1f6f716d6ea), subdomain=sapit-strategicservices-dev)
PrincipalAccessor.getCurrentPrincipal()
com.sap.cloud.sdk.cloudplatform.security.principal.exception.PrincipalAccessException: Could not read a principal from neither a given JWT nor a given Basic Authentication header.
at com.sap.cloud.sdk.cloudplatform.security.principal.ScpCfPrincipalFacade.createFallbackException(ScpCfPrincipalFacade.java:92) ~[security-scp-cf-3.45.0.jar:na]
Suppressed: com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextAccessException: No ThreadContext available for thread id=188.
But I can read the authentication header and JWT from the request with this example:
@GetMapping("/headers/show")
public HttpHeaders showHeaders(ServerWebExchange exchange) {
var headers = exchange.getRequest().getHeaders();
return headers;
}
That's why I asked whether webflux is in general supported.
We conclude that the SAP Cloud SDK does not work together with Spring WebFlux until today.
We will update this issue in case the compatibility will be provided.
Hey @nbblum,
We've added a note to our docs that Spring WebFlux is not yet supported by the SAP Cloud SDK. Earliest we might look into this direction is somewhere next year. If there will be coming more requests with production-ready use cases to supporting WebFlux we might reconsider the priorities.
In the meanwhile, you can use the classical Java threading model together with Java SDK and Spring Boot.
I'll be closing this issue for now. Don't hesitate to re-open it if you have any questions.
Issue Description
I'm trying to fetch a destination by name
DestinationAccessor.getDestination(name);
but get an exception. The destination exists and and a destination service is bound in cloud foundry. It seems that the authentication information cannot be read from the request. Could this be an issue with webflux?Impact / Priority
Affected development phase: Development, Impact: Blocked
Error Message
Dependency Tree
Project Details
Checklist