cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP Java: Get Multitenancy Dependencies

christoffer_fuss
Participant
0 Kudos
1,264

Hi all,

we are developing a CAP Java multitenant application and have some problems with consuming dependent services: the destination service, the connectivity service and the html5-apps-repo service.
In Node.js the dependencies are coming on the fly:

In my CAP Java application I just get the root dependency for XSUAA:


In the documentation I saw that I need to react to the GET_DEPENDENY_EVENT

import com.sap.cloud.mt.subscription.json.ApplicationDependency;

@Value("${vcap.services.<my-service-instance>.credentials.xsappname}")
private String xsappname;

@On(event = MtSubscriptionService.EVENT_GET_DEPENDENCIES)
public void onGetDependencies(MtGetDependenciesEventContext context) {
ApplicationDependency dependency = new ApplicationDependency();
dependency.xsappname = xsappname;
List<ApplicationDependency> dependencies = new ArrayList<>();
dependencies.add(dependency);
context.setResult(dependencies);
}

When I do this, the subscription fails with the error:

There is only a value set for the xsappname and all the other attributes like appId and appName are null. In the code above I just set value for xsappname but I dont know how to pass the other attributes because the methods are deprecated:


So what is the correct way to fetch the dependencies?

Best regrads and many thanks,
Chris

Accepted Solutions (1)

Accepted Solutions (1)

marcbecker
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

"capmt-datatrainhubtest-datatrain" doesn't look like a valid xsappname. Where did you get that from?

The xsappname that you need to return in the dependencies is the XSUAA OAuth2 Client of your service instance. In case of a destination service binding you can find the correct value in the "xsappname" property of the credentials.

Best regards,
Marc

christoffer_fuss
Participant
0 Kudos

Thaks, I was using the wrong xsappame as you suggested 🙂 It is working fine now 🙂 I had to use the xsappname for the destination service and the connecivity service.

Best regards and many thanks,

Chris

rashmiangadi
Associate
Associate
0 Kudos
Where do I need to add this method any examples ?

Answers (0)