Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Tagmanager.resolve all returns null on AEM 6.5 publish instance

Avatar

Level 2

Hi,

 

I am facing an issue where the Tags are not being resolved on AEM 6.5 publish instance.

 

The following code is being used to resolve the tag

final TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
final Tag tag = tagManager.resolve("/content/cq:tags/abc");

On AEM Author, tags are resolved correctly, but the same code is returning null on publish instance.

 

The things which I have checked on publish instance:

1. Tags are available on publish instance

2. service user used for resolving the tags is available on publish instance

3. read and write permissions are provided for /content/cq:tags

 

Please let me know if there is anything else that needs to be checked.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @SmrithiGo 
Could you please check logs, seems your service user is not correct bind with your bundle.

check the Service Mappings:

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/apache-sling-service-user-... 

 

@Reference
private ResourceResolverFactory resolverFactory;
 
@Activate
public void doSomething(ComponentContext ctx) {
   Map<String, Object> param = new HashMap<String, Object>();
   param.put(ResourceResolverFactory.SUBSERVICE, "read-service");
   ResourceResolver resolver = null;
   try {
	resolver = resolverFactory.getServiceResourceResolver(param);


Arun Patidar

View solution in original post

9 Replies

Avatar

Community Advisor

@SmrithiGo ,

 

You are already doing the basic checks that needed to be done to debug this issue. Maybe to further debug this you can try the following:

1) Confirm tagManager object is not null

2) Check what is the path that is being passed as parameter in the resolve(). Print that path in the logs or use breakpoints if the debugging is done in local machine.

3) Double check that the service user used to read/write the tags has read permission to the "/content/cq:tags/abc" path.

 

Hope this helps.

Avatar

Level 2

Thank you for you response. Please find my answers:

 

1. yes, tagmanager is not null

2. the page is /content/cq:tags/abc (it is basically the namespace created for the proejct). I am not passing the tagID, instead the path of the tag.

3. Yes, service user has both read and write permissions on publish. i tired by giving all the permission to see if I am missing something. But still it is throwing null. 

 

Avatar

Community Advisor

I see. Is the /content/cq:tags/abc has the jcr:primaryType as cq:Tag?

Avatar

Community Advisor

Hi @SmrithiGo 
Does it works in your local or any of the AEM instance.

 

Could you try to publish tags and try below servlet in your local : https://github.com/arunpatidar02/aem63app-repo/blob/master/java/GetTags.java 

This is the working & tested example.



Arun Patidar

Avatar

Level 2

Hi @arunpatidar ,

Thank you for sharing this code.

 

I have tested it on my publish instance and I can see that the servlet is returning the tag titles. This is the result that I got.

 

Hat Tag details(Content) Hat

Hat Tag details(etc) Hat

 

here you have created the tagmanager object as below:

TagManager tagManager = req.getResourceResolver().adaptTo(TagManager.class);

I am trying to get the tagmanager object using the custom service user. And i think it has something to do with the permissions. But I have tried giving all the permissions for the service users on publish, but still not working.

Avatar

Level 2

I tired getting the resource of the tag using the path using the below code and the tagResource is null. 

resourceResolver = getResolver.getServiceResolver();
Resource tagResource = resourceResolver.getResource(tagResource);

The service user is unable to get the tag resource.

Avatar

Correct answer by
Community Advisor

Hi @SmrithiGo 
Could you please check logs, seems your service user is not correct bind with your bundle.

check the Service Mappings:

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/apache-sling-service-user-... 

 

@Reference
private ResourceResolverFactory resolverFactory;
 
@Activate
public void doSomething(ComponentContext ctx) {
   Map<String, Object> param = new HashMap<String, Object>();
   param.put(ResourceResolverFactory.SUBSERVICE, "read-service");
   ResourceResolver resolver = null;
   try {
	resolver = resolverFactory.getServiceResourceResolver(param);


Arun Patidar

Avatar

Level 2

Thank you so much. You saved my day

 

The tags are showing up on my publish instance. The changes that I did are the following:

 

1. I had created a nt:file org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~identifier.cfg.json with the following properties within it

{
"user.mapping" : [
"bundleId:subServiceName=[serviceUsercreated]"
]

}

Now I changed it to a sling:osgiConfig node as mentioned in this article: Solved: Apache Sling Service User Mapper Service Amendment... - Adobe Experience League Community - ...

It worked. Thank you once again