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

Error in getServiceResourceResolver method

Level 4
Level 4

Hi Experts,

We are creating one custom workflow to move assets from draft folder to final folder in AEM 6.4. When creating the resourceResolver object then getting below error. I have also attached the code snippet.


com.x.x.core.workflow.DraftToFinalMove exceptionb::::

java.lang.NullPointerException: null

at com.x.x.core.workflow.DraftToFinalMove.execute( [com.cox.core:0.0.1.SNAPSHOT]

at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess( [com.adobe.granite.workflow.core:2.0.168]

at com.adobe.granite.workflow.core.job.JobHandler.process( [com.adobe.granite.workflow.core:2.0.168]

at$JobConsumerWrapper.process( []

at []

at$100( []

at$ []

at java.util.concurrent.ThreadPoolExecutor.runWorker(

at java.util.concurrent.ThreadPoolExecutor$


Can anyone guide us like what we are missing.



8 Replies
Level 4
Level 4

package com.x.x.core.workflow;

import java.util.Collections;

import java.util.HashMap;

import java.util.Map;

import javax.jcr.Node;

import javax.jcr.NodeIterator;

import javax.jcr.Session;

import javax.jcr.query.Query;

import javax.jcr.query.QueryManager;

import javax.jcr.query.QueryResult;

//import org.apache.felix.scr.annotations.Component;

import org.osgi.service.component.annotations.Component;

import org.apache.felix.scr.annotations.Properties;

import org.apache.felix.scr.annotations.Property;

import org.apache.felix.scr.annotations.Service;

import org.osgi.framework.Constants;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import com.adobe.granite.workflow.WorkflowException;

import com.adobe.granite.workflow.WorkflowSession;

import com.adobe.granite.workflow.exec.WorkItem;

import com.adobe.granite.workflow.exec.WorkflowProcess;

import com.adobe.granite.workflow.metadata.MetaDataMap;

import org.apache.felix.scr.annotations.Reference;

//Sling Imports

import ;



//This is a component so it can provide or consume services


    @Property(name = Constants.SERVICE_DESCRIPTION, value = "Draft to Final Move Assets Description"),

    @Property(name = Constants.SERVICE_VENDOR, value = "Adobe"),

    @Property(name = "process.label", value = "Draft to Final Move Assets Label") })


    immediate = true,

    service = WorkflowProcess.class,

    configurationPid = "com.x.x.core.workflow.DraftToFinalMove"


public class DraftToFinalMove implements WorkflowProcess{

/** Default log. */

protected final Logger log = LoggerFactory.getLogger(this.getClass());

private Session session;         

//Inject a Sling ResourceResolverFactory


private ResourceResolverFactory resolverFactory;


public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args) throws WorkflowException {"**** execute method here");

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

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

        ResourceResolver resourceResolver = null;


//get Current assinee from workflow

String currentAssinee = item.getCurrentAssignee();"currentAssinee::"+currentAssinee);

String copyPath = null;

String assetPath = null;

ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);

session = resourceResolver.adaptTo(Session.class);

com.adobe.granite.asset.api.AssetManager assetManager = resourceResolver.adaptTo(com.adobe.granite.asset.api.AssetManager.class);

QueryManager qm = session.getWorkspace().getQueryManager();

Query q = qm.createQuery("/jcr:root/content/dam/dal/bos-workflow/bga/draft//*[jcr:primaryType='dam:Asset']", "xpath");

QueryResult result = q.execute();

NodeIterator nIt = result.getNodes();

StringBuilder output = new StringBuilder();"assetPath:2: ");

while (nIt.hasNext()) {

Node node = nIt.nextNode();

assetPath = "/content/dam/dal/bos-workflow/bga/draft/"+node.getName();

copyPath = "/content/dam/dal/bos-workflow/bga/final/"+node.getName();

assetManager.moveAsset(assetPath, copyPath);


// Log out;

session.logout();"Successfully Moved the Assets!!!");


catch(Exception e)






Level 3
Level 3


Have you created system user to get service resource resolver with name datawrite ??

if not make sure to create system user.

After creating system user you need to register your service using Apache Sling Service User Mapper Service

You can refer below article for creating system user for example ;

How to get Service Resource Resolver? – Rahul Mengji

Level 4
Level 4

Hi Vipin,

Yes i have configured the system user and also added the entry into user mapper, and restarted the instance but still same error.

it is failing at line

ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);

And throwing the same error.



Level 3
Level 3


I don't see setter method defined for resolverFactory, could you add and try.

Level 4
Level 4

Which setter method, i didn't get that. Can you give me more details please.

Level 3
Level 3


Could you put a debugger and see if you are getting resolverFactory as null , if yes than keep setter method (like any other java normal getter/setter method) .

Or if resolverFactory is not null than it is an issue with your system user and its permissions. Assign system user to administrators group and try.


Also you are mixing annotations (osgi and felix)

import org.osgi.service.component.annotations.Component;

import org.apache.felix.scr.annotations.Properties;

import org.apache.felix.scr.annotations.Property;

Community Advisor
Community Advisor

Hi Samer,

You can do it without system user but can do by normal admin session by white-listing the bundle.

See this article: Adobe Experience Manager Help | Moving Adobe Experience Manager DAM Assets using the Granite AssetMa...

Hope this helps!!


Ratna Kumar.