cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Subscribe to the Multi-tenant application in BTP Dashboard due to Dependency Error

0 Kudos

I am trying to deploy a multi-tenant application(Spring boot application) with SAAS service registry in the SAP CF.When i do the subscribing,I am getting the following error

Error :

I have created 3 End points in my Controller in Spring boot application:

  1. PUT (Subscribing)
  2. DELETE (Unsubscribe)
  3. GET (Get Dependencies) (I have added <VCAP_SERVICES.<service>.credentials.xsappname for saasregistry,connectivity,destination,xsuaa)

Could someone please look into this and do the needful

0 Kudos

Thank you so much carlos.roggan and gregorwolf ,now i am able to create a fully multi-service application.you guys have answered all of my questions very clearly and patiently.

Regards

Singamsetty Maruthi Srinivas

gregorw
Active Contributor
0 Kudos

You should confirm one of the answers.

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor

Answers (2)

Answers (2)

CarlosRoggan
Product and Topic Expert
Product and Topic Expert

Hi, I'm wondering about the json structure in your response.
I've checked an example on my side, I'm returning a json like this:

res.status(200).json([{'xsappname': CREDENTIALS.uaa.xsappname }])

So I don't have the "dependencies" node, and I don't have an array of strings, but I have and array of objects with the propertyname "xsappname"
Maybe you can try adapting your response structure?

0 Kudos

Got it,Could you let me know what all XSAPPNAMEs should we add....should we add XSAPPNAMEs of all the 4(saasregistry,connectivity,destination,xsuaa) ? or what all should be added in the response?

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

As far as I understand the SaaS mechanism, the dependencies are meant to be used as follows:
You write a multi tenant aware app
Your app has dependencies on other services
The other services are multi-tenant aware as well
As such, they need to be informed about your app
Like that, the service can distinguish the tenants of your app, instead of the app as a whole.
To achieve it, the other services are added as dependencies in your MT app
So the other services are invoked before your app is invoked
So the other services as well define the MT callbacks which are invoked
The saasregistry handles these tasks: build a dependency tree and invoke the services and your app in the correct order.
As such, I don’t think that you need to add the saasregistry as dependency in your app
Also the xsuaa: in the xs-security.json, you declare that the xsuaa instance has tenantMode:shared
It is anyways treated as multitenant-aware service

So I don’t think you need to add it as dependency in your dependencies-callback

Kind Regards,
Carlos

0 Kudos

Hey carlos.roggan ,do we need to place the xs-security.json in the Spring boot App ? if yes where should we place it...any resources regarding this will be very helpful.

Regards,

Singamsetty Maruthi Srinivas

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,
the xs-security.json file is just a storage for configuration parameters.
Actually, you don't even need that file.
You need to pass configuration params, when creating the instance of the service.
You can pass these json params in the cloud cockpit in the wizard.
Or directly pass the json in the command line.
But best practice is to use a file and check it in github.
The name of the file is of your choice.
Also the location.
As mentioned, it is only required during instance creation

0 Kudos

Hey carlos.roggan

Do we need to develop an Approuter for achieving Multi-tenancy or it aint required?

Regards

Singamsetty Maruthi Srinivas

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Approuter is a little application that is typically used together with web apps
Approuter is then placed in front of the web app.
The end user opens the approuter URL
approuter takes care of authentication (bound to xsuaa)
After login, approuter forwards the user to the web app
Approuter also is used to avoid CORS problem
Approuter supports multitenancy
But it is not a prerequisite.
If you use approuter, make sure to add the HOST_PATTERN variable to the manifest

0 Kudos

Hello carlos.roggan ,According to your inputs,i have created a new XSUAA service with the below xs-security.json in the cockpit

{
"xsappname": "Exploration-tenant",
"tenant-mode": "shared",
"description": "Security profile of inventory management app",
"scopes": [{
"name": "$XSAPPNAME.Callback",
"description": "With this scope set, the callbacks for tenant onboarding, offboarding and getDependencies can be called.",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
}]
}

I have also created the SAAS registry with the following config.json in the cockpit

{
"tenantmode" : "shared",
"appId": "multi-tenant-app-stestartplatform!t10211",
"displayName": "Forum Multi-tenant ",
"description": "A sample hello world app to explain the concepts of Multitenancy",
"category": "Provider ZZZ",
"appUrls": {
"onSubscription": "https://Exploration-tenant.cfapps.sap.hana.ondemand.com/callback/tenant/{tenantId}"
}
}

I have deleted the getDependencies endpoint in the Spring boot application,now there are only two endpoints 1) PUT(for tenant-onboarding) 2)DELETE (for tenant-offboarding)

Please find the below manifest.yml of the Spring boot application:

Now when i try to subscribe to the application,I am getting the following error...Could you please look into this and do the needful.

gregorw
Active Contributor
0 Kudos

Seems you're a step further. Now you should return the subscriptionUrl

0 Kudos

Hey gregorwolf ,Could you please let me know How and where to mention that.

Regards,

Singamsetty Maruthi Srinivas

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,
Just guessing....
so you've added these 4 services as dependencies?

saasregistry,
connectivity,
destination,
xsuaa
?
Are you sure that you need dependency to saasregistry and xsuaa?
Have you checked if the <VCAP_SERVICES.<service>.credentials.xsappname always refurns a valid value?

0 Kudos

Hello,thanks for responding,Initially i have added all the 4(saasregistry,connectivity,destination,xsuaa) XSAPPNAME's in the getDependencies endpoint.I have also added them as services in the manifest.yml.Now i tried only adding connectivity's and destinations XSAPPNAME's but the result remains same,it is giving me the same error.and regarding "Have you checked if the <VCAP_SERVICES.<service>.credentials.xsappname always refurns a valid value?" I have given XSAPPNAMEs in a hardcoded manner.

Could you please look into this issue and do the needful....

I am pasting the Tenant onboarding and offboarding Controller code for your reference :

	@PutMapping("/{tenantId}")
	public void subscribeTenant(@PathVariable(value = "tenantId") String tenantId) {
		logger.error("Tenant callback service was called with method PUT for tenant {}.", tenantId);

	}

	@DeleteMapping("/{tenantId}")
	@ResponseStatus(HttpStatus.NO_CONTENT)
	public void unsubscribeTenant(@PathVariable(value = "tenantId") String tenantId) {
		logger.error("Tenant callback service was called with method DELETE for tenant {}.", tenantId);

	}

	@GetMapping("/dependencies")
	public ArrayList<deps> getDependancies(HttpServletRequest request, HttpServletResponse response) {
		response.setStatus(200);
		response.setContentType("application/json");
		ArrayList<String> arr = new ArrayList<String>();
		arr.add(CONNECTIVITY_XSAPPNAME);
		arr.add(DESTINATION_XSAPPNAME);
deps d=new deps(); d.setDependencies(arr); ArrayList<deps> res = new ArrayList<>(); res.add(d); return res; }
The error i was getting after i gave only Connectivity and Destination's XSAPPNAME's :

gregorw
Active Contributor
0 Kudos

Have you checked the actual response returned from a request to your getDependencies endpoint?

0 Kudos

Hey gregorwolf ,I have checked it.I am pasting it here