Fetching Cloud Configuration Returns Null in AEM Publish Instance
Hello Adobe Experience Manager Community,
I’m currently working on implementing a custom cloud service in AEM using the official documentation.
Progress so far:
- I have successfully set up and stored the cloud configuration on the Author instance.
- I can also configure my site with the cloud configuration on the Author instance without any issues.
Problem:
When I attempt to fetch the configuration on the Publish instance, it always returns null.
Code:-
HierarchyNodeInheritanceValueMap pageProperties1 = new HierarchyNodeInheritanceValueMap(resource);
String[] services = pageProperties1.getInherited("cq:cloudserviceconfigs", new String[]{});
// Fetch the DataReader service
final DataReader milestoneSchemaJSONReader = sling.getService(DataReader.class);
// Retrieve the ResourceResolver
ResourceResolver resolver = milestoneSchemaJSONReader.getResourceResolver();
// Adapt resolver to ConfigurationManager
ConfigurationManager cfgMgr = resolver.adaptTo(ConfigurationManager.class);
// Retrieve the configuration
Configuration cfg = cfgMgr.getConfiguration("milestoneschema", services);
if (cfg != null) {
out.println("Configuration is available.");
} else {
out.println("Configuration is null.");
return;
}
I also tried this approach:
String[] services = pageProperties.getInherited("cq:cloudserviceconfigs", new String[]{});
ConfigurationManager cfgMgr = resource.getResourceResolver().adaptTo(ConfigurationManager.class);
I have checked in crxde at that node properties are present. Please help with any solution.