ResourceResolver resolve method not working as expected (6.1) | Community
Skip to main content
New Participant
May 31, 2017
Solved

ResourceResolver resolve method not working as expected (6.1)

  • May 31, 2017
  • 3 replies
  • 2242 views

I am using AEM 6.1 and am experiencing some weird behaviour with the 'resolve' method of the ResourceResolver.

I have a bunch of mappings that work correctly on the live site, when I use the '.../system/console/jcrresolver' to test my mappings I get the following result:

'https://acc-company.com/nl/size-guides' is correctly resolved into '/content/www-company-com/nl/size-guides'

When I try to use the resolve method from ResourceResolver in code I do get a wrong result:

resourceResolver.resolve("https://acc-company.com/nl/size-guides").getPath();

Results in: '/https://acc-company.com/nl/size-guides', why am I not receiving '/content/www-company-com/nl/size-guides' ?

NOTE: mapping (the reverse of resolving) does work when triggered from code:

resourceResolver.map("/content/www-company-com/nl/size-guides");

Results in: 'https://acc-company.com/nl/size-guides'

Any idea what is causing the resolving to fail?

Thanks in advance

Jeroen

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

3 replies

cquser1
cquser1Accepted solution
New Participant
May 31, 2017
New Participant
May 31, 2017

Hey

The result of the resolve is a 'NonExistingResource' so it's pointless to call 'adaptTo' on this because it will result in 'null'

cquser1
New Participant
May 31, 2017

Hi,

Not pretty sure, but just a thought.

After doing Resource resource = resolver.resolve(pagePath), You might want to use adaptTo() like resource.adaptTo(Page.class) and then do a getPath() on it and see if it helps.