New Resource Resolver Search Path Breaks Template Policies

Description

Adding a resource resolver search path ("/apps/proj1") through script:

org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.cfg.json
{
"resource.resolver.searchpath":
"/apps/proj1",
"/apps",
"/libs"

}

Breaks all policies defined in /conf/proj1/settings/wcm/policies.
Definitions in policies.xml exist, but it is not possible to relate them to editable page templates, and all previous policy selections in templates are broken. Only removing the line '/apps/proj1' from thr cfg.json script, gets the defined policies back to the previous working state.

This can be reproduced using the following steps:

1-Create any policy related to a specific component on a specific page template
2-Ssave the template with chosen policy
3-Add script with

resource.resolver.searchpath":
"/apps/projname"...

4-Confirm that defined policy for the template and related comonent is no longer possible to get selected in the dropdown on edit template.

Resolution

As best practice, avoid amending '/apps' and '/libs'. ``Sling would look for components "First in /apps, then /libs”. Well the truth is that Sling will go down this list and look for resources by going through this list in order. Thus, things in '/apps' (unless specified using '/libs' at the beginning of the path) will be found first and that is why how that overlay works.

On this page