Skip to main content
CT1012
Level 4
December 12, 2017
Question

AEM 6.3 System user - Resource resolver issue

  • December 12, 2017
  • 3 replies
  • 3316 views

On AEM 6.3 we've a custom quick links search where we map keywords to outer links.

We created system user and mapped it using Apache sling Service User Mapper Service. System user is given required permissions in user admin.

We used the following code for sub service

@Activate

protected void activate() throws RepositoryException {

Map<String, Object> param = new HashMap<String, Object>();

        param.put(ResourceResolverFactory.SUBSERVICE, "searchService");

        ResourceResolver resolver = null;

     

        try {

resolver = resolverFactory.getServiceResourceResolver(param);

adminSession = resolver.adaptTo(Session.class);

         

        } catch (Exception e) {

log.error("ERROR" + e + e.getStackTrace().toString());

e.printStackTrace();

}

}

We're seeing the following Null pointer during search

*ERROR* [0:0:0:0:0:0:0:1 [1513035725695] GET /bin/amica/searchServlet HTTP/1.1] com.******.adc.******com.core.search.SearchServlet ERRORjava.lang.NullPointerException[Ljava.lang.StackTraceElement;@3d05a33d

For the custom quick links we are using

public JSONArray performSearch(String queryTerm,

SlingHttpServletRequest request) throws RepositoryException,

JSONException {

String resourcePath = searchConfigurationService.getSearchQuicklinksAdminNodePath();

ResourceResolver resourceResolver = request.getResourceResolver();

        Resource res = resourceResolver.getResource(resourcePath);

We can see the  resourcePath through log info but unable to resolve the resource. No error logs on this.

This search working on author but not on publish, seems to be an authentication issue. Even tried using Ensure Service User​   for creating user and permissions.

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

3 replies

smacdonald2008
Level 10
December 12, 2017

If it works on Author - make sure all of the same users, etc are setup. What works on Author has to work on Pub if everything is setup the same.

CT1012
CT1012Author
Level 4
December 12, 2017

Pub has everything same as author.... We found this isn't working

ResourceResolver resourceResolver = request.getResourceResolver();

Level 2
December 13, 2017

resolverFactory.getServiceResourceResolver(param);

is the correct way of getting resolver. If you are getting Nullpointer exception, check if the system user exists on publish.

Try changing the user like giving 'OAuthUser' in the User Mapper Service if the issue persists.