Whenever I am trying to do TagManager.getNameSpaces()
I am getting null pointer Exception.
My Tags are present under /content/cq:tags/
Also I have installed Service Pack 6.4.3
Also resourceResolver is having readSystem as subservice.
Can you anyone help on this?
Hi sagarv13144480 ,
As you're using the service user to read the tags.Can you please make sure the below things:
<bundle symbolic name>:<any name of service>=<system user id>
I think its because, the sling request is not sent in your servlet.I also faced the same issue.Try using sling request in resource resolver.I Hope it will work.
private static final String tagid = "/content/cq:tags/properties";
TagManager tagManager = slingRequest.getResourceResolver().adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagid);
Resource resource = slingRequest.getResourceResolver().getResource(tagid);
Tag pagetag = tagManager.getTags(resource);
In which statement do you get the NPE? Please ensure that you check the return value of the adaptTo() call. But also resourceResolver.getResource() can return null if the resource does not exist.
Does your service user have read permission on /content/cq:tags?
resourceResolver = resourceResolverFactory.getServiceResourceResolver(Map having readSystem subservice)
Resource resource = resourceResolver.getResource("/content/cq:Tags");
TagManager tagMgr = resource.adaptTo(TagManager.class);
Tag Tags = tagMgr.getNamespaces();
Can you please check if resourceResolver is not null?
If it is not null, then you can do
TagManager tm = resourceResolver.adaptTo(TagManager.class)