Fetching Cloud Configuration Returns Null in AEM Publish Instance | Community
Skip to main content
Level 2
January 2, 2025

Fetching Cloud Configuration Returns Null in AEM Publish Instance

  • January 2, 2025
  • 4 replies
  • 1120 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

daniel-strmecki
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 2, 2025

Hi @manishkaith1,

I never used the ConfigurationManager class on my project, but I suspect the issue might be the resource resolver you are using to adapt to the ConfigurationManager.

If that resolver comes from the request then it's probably the anonymous user on the publisher with little permission. If you are not already using a service user try that and check the service user permissions on Publisher.

 

Good luck,

Daniel

Level 2
January 3, 2025

Thanks Daniel for the reply.
I already have a system user which was created using the osgi config folder present in config module of aem archetype project.

org.apache.sling.jcr.repoinit.RepositoryInitializer~milestoneSchema.cfg.json

{ "scripts": [ "create path (sling:OrderedFolder) /content/dam/milestoneSchema", "create path (nt:unstructured) /content/dam/milestoneSchema/jcr:content", "set properties on /content/dam/milestoneSchema/jcr:content\n set cq:conf{String} to /conf/milestoneSchema\n set jcr:title{String} to \"Milestone Schema Connector\"\nend", "create service user aem-milestone-schema-service-user with forced path system/cq:services/milestoneschema", "set ACL for aem-milestone-schema-service-user\n allow jcr:read on /etc/cloudservices\nend", "set ACL for aem-milestone-schema-service-user\n allow jcr:read,jcr:lockManagement,jcr:versionManagement,rep:write,crx:replicate on /content\nend", "set ACL for aem-milestone-schema-service-user\n allow jcr:read,rep:write on /conf\nend" ] }

org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~milestoneschema.cfg.json

{ "user.mapping": [ "com.milestone.schema.core:milestone-schema-service=[aem-milestone-schema-service-user]" ] }


Also the resolver i use to get from data reader service.

public ResourceResolver getResourceResolver() throws LoginException { LOG.info("DataReader::getResourceResolver - Getting resource resolver..."); Map<String, Object> param = new HashMap<>(); param.put(ResourceResolverFactory.SUBSERVICE, "milestone-schema-service"); ResourceResolver resolver = resolverFactory.getServiceResourceResolver(param); if (resolver != null) { LOG.info("DataReader::getResourceResolver - Resource resolver obtained successfully."); } else { LOG.error("DataReader::getResourceResolver - Failed to obtain resource resolver."); } return resolver; }



But still the config is null. Also all replication are done correctly on publish instance. I checked the same with elevated permission of repository.

aanchal-sikka
Community Advisor
Community Advisor
January 3, 2025

@manishkaith1 

 

I have not used the API, but if its working on Author but not on publish, requesting you to assure following:

  • The Parent page where the configuration is done is replicated to publish.
  • The Cloud config that it uses is also replicated to publish.
  • Assure the session that uses that configuration has sufficient privileges to access the Cloud configs.
Aanchal Sikka
Level 2
January 3, 2025

Thanks Aanchal for the reply.
I already have a system user which was created using the osgi config folder present in config module of aem archetype project.

org.apache.sling.jcr.repoinit.RepositoryInitializer~milestoneSchema.cfg.json

 

{ "scripts": [ "create path (sling:OrderedFolder) /content/dam/milestoneSchema", "create path (nt:unstructured) /content/dam/milestoneSchema/jcr:content", "set properties on /content/dam/milestoneSchema/jcr:content\n set cq:conf{String} to /conf/milestoneSchema\n set jcr:title{String} to \"Milestone Schema Connector\"\nend", "create service user aem-milestone-schema-service-user with forced path system/cq:services/milestoneschema", "set ACL for aem-milestone-schema-service-user\n allow jcr:read on /etc/cloudservices\nend", "set ACL for aem-milestone-schema-service-user\n allow jcr:read,jcr:lockManagement,jcr:versionManagement,rep:write,crx:replicate on /content\nend", "set ACL for aem-milestone-schema-service-user\n allow jcr:read,rep:write on /conf\nend" ] }

 

org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~milestoneschema.cfg.json

 

{ "user.mapping": [ "com.milestone.schema.core:milestone-schema-service=[aem-milestone-schema-service-user]" ] }

 


Also the resolver i use to get from data reader service.

 

public ResourceResolver getResourceResolver() throws LoginException { LOG.info("DataReader::getResourceResolver - Getting resource resolver..."); Map<String, Object> param = new HashMap<>(); param.put(ResourceResolverFactory.SUBSERVICE, "milestone-schema-service"); ResourceResolver resolver = resolverFactory.getServiceResourceResolver(param); if (resolver != null) { LOG.info("DataReader::getResourceResolver - Resource resolver obtained successfully."); } else { LOG.error("DataReader::getResourceResolver - Failed to obtain resource resolver."); } return resolver; }

 



But still the config is null. Also all replication are done correctly on publish instance. I checked the same with elevated permission of repository.

arunpatidar
Community Advisor
Community Advisor
January 3, 2025

Hi @manishkaith1 

If it works on Author but not on Publish, the issue could be related to permissions or the configuration of the Publish environment.

Try accessing Publish locally using an admin account to see if it works. If it doesn't, deploy the cloud configuration using a package and check again.

 

Arun Patidar
kautuk_sahni
Community Manager
Community Manager
January 7, 2025

@manishkaith1 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
Level 2
January 8, 2025

Currently not found any solution for my Proble.
Do anyone have idea how can i access the same properties any other way.