Expand my Community achievements bar.

SOLVED

[AEM 6.5] [OSX Catalina] ResourceResolver.getResource() returns null from workflow participant chooser service for valid path. But it resolves correctly from workflow process service.

Avatar

Level 2

Hi, I'm building a workflow that first prompts the initiator for assignee and stores it in the payload node.  The next step is Dynamic Participant step, and we have a ParticipantChooser (implements both ParticipantStepChooser and ParameterizedParticipantService) class that retrieves the value from payload node, and assigns the workflow accordingly.  In this ParticipantChooser, it first attempts to resolve the payload itself.  Here is sanitized code, note the comments:

public String getParticipant(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
            throws WorkflowException {
        WorkflowData workflowData = workItem.getWorkflowData();
        if (workflowData.getPayloadType().equals(PayloadMap.TYPE_JCR_PATH)) {
            String path = workflowData.getPayload().toString();
            ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
            // path is correct
            Resource resource = resourceResolver.getResource(path);
            // resource is null 
            if (resource != null && resource.isResourceType(NameConstants.NT_PAGE)) {
                // this block never executes
            }
        }
        return workItem.getWorkflow().getInitiator();
    }



I've played around and it pretty much cannot resolve any node on the site.  Instead it does the fallback code and assigns to WF initiator.  In my case I'm just using admin user.

Later in the chain I have a custom workflow process that performs the relevant action for the workflow.  This uses the exact same strategy to resolve the payload resource, and it works just fine.

Another strange thing is that this step chooser has been around at my company before I was even hired, and I haven't changed it.  And yet the WF Process I just wrote from scratch and it works correctly.  I'm guessing this is some sort of configuration problem in my local instance but I have very few ideas about what that might be.

Any help is appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Nevermind, figured it out.  Apparently AEM runs these services as specific users in AEM.  The (non-working) chooser is run by "workflow-service" and the (working) workflow process is run by "workflow-process-service".  

"workflow-service" did not have permissions to read /content.  Going to the UserAdmin page and granting that permission made it work.  Not sure if that's how it is OOTB or if something got messed up in my installation.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Nevermind, figured it out.  Apparently AEM runs these services as specific users in AEM.  The (non-working) chooser is run by "workflow-service" and the (working) workflow process is run by "workflow-process-service".  

"workflow-service" did not have permissions to read /content.  Going to the UserAdmin page and granting that permission made it work.  Not sure if that's how it is OOTB or if something got messed up in my installation.