Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges


Apache Sling Context Aware Configuration: get the effective node where configuration is defined


Level 1

Given a hierarchy of CAC configurations defined at multiple levels, for example:




Suppose that I have the resource for `bloodhound` and then I do:

ConfigurationBuilder builder = resource.adaptTo(ConfigurationBuilder.class);
myConfig =;

I can access the configuration properties as needed, but how to get the path where the actual configuration is defined which in this case would be path of CAC2 i.e. /content/en/animals/dogs?

I tried something like:

private ConfigurationResourceResolver configResourceResolver;
contextPath = configResourceResolver.getContextPath(resource);

but contextPath always returns /content/en/animals/dogs/hound/bloodhound and NOT  /content/en/animals/dogs which is what is required for my use case.

I have also tried

realContextPath = configResourceResolver.getResource(resource, "sling:configs", MyConfig.class.getName())

but this always returns null.
Is there a way to do it via the API?

Note: I'm using caconfig with the editor and extras.

1 Accepted Solution


Correct answer by
Community Advisor
1 Reply


Correct answer by
Community Advisor