SAP / cloud-security-services-integration-library

Integration libraries and samples for authenticating users and clients bound to XSUAA authentication and authorization service or Identity authentication service.
Apache License 2.0
151 stars 135 forks source link

Unable to start application in CF with Service plan "reference-instance" #1435

Closed VasudhaRao closed 9 months ago

VasudhaRao commented 10 months ago

We have a Java application in Cloud Foundry. We are unable to start our application. This is the error which we have received in the logs. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.sap.gs.translationhub.proxy.ProxyApplication]; nested exception is java.lang.IllegalArgumentException: No enum constant com.sap.cloud.security.config.cf.CFConstants.Plan.REFERENCE-INSTANCE

The same application works fine for Service Plan- "Broker". We have also referenced this issue "https://github.com/SAP/cloud-security-services-integration-library/issues/1279" where getServiceConfigurationsAsList is mentioned. But we could not find the package to import. Also, tried adding this configuration in WebSecurityConfiguration file, but could not reach this point as application failed to start. Environments.getCurrent().getXsuaaConfiguration().getProperty(SERVICE_PLAN).equals("reference-item");

We have created the reference-instance in the following manner. We have created a service instance in Kyma and we are using reference-instance plan to use it in our CF application.

Adding the logs of our application.

Could you let us know, how we could configure the "reference-instance" in our application.

sth proxy logs.txt

finkmanAtSap commented 10 months ago

Hi, I am taking a guess here that you are using version 2.x of the lib since you have CFConstants on the classpath.

In this case, the getServiceConfigurationsAsList method exists as well but it has been added in a recent version, if I remember correctly:

https://github.com/SAP/cloud-security-services-integration-library/blob/fdabc30eac5fbe02f2fab8f5d28802feacce274f/java-api/src/main/java/com/sap/cloud/security/config/Environment.java#L77 https://github.wdf.sap.corp/I577963/cloud-security-services-integration-library-private/blob/fdabc30eac5fbe02f2fab8f5d28802feacce274f/java-api/src/main/java/com/sap/cloud/security/config/Environment.java#L77

Please try to follow the steps I have written in the linked issue beginning with

By default, you can call Environments.getCurrent() to get a ServiceBindingEnvironment object on which you can call the method.

which should return a CFEnvironment object on versions 2.x, but, under the hood, work the same.

Best, Manuel

VasudhaRao commented 9 months ago

Hi Manuel, We have raised the issue in Stack@SAP, but could not get any response to our query. https://sap.stackenterprise.co/questions/49039

The solution provided in the ticket works fine for non spring based application. We also found a similar issue raised for XSUUA service plan "apiaccess". https://github.com/SAP/cloud-security-services-integration-library/issues/382 . This issue is resolved as APIACCESS is now available in ENUM Plan.

The issue continues to exist even after making the changes. Could you please look into it? Also, attaching the java-api library imported by team, with CFConstants.
xsuaa

Thanks and Regards, Vasudha

finkmanAtSap commented 9 months ago

Answered on Stack@SAP