Expand my Community achievements bar.

Getting WorkflowException and AccessDeniedException when try to invoke workflow

Avatar

Level 2

I have used both AEM 6.4 and 6.5 instance where i have to start workflow after replication listener. Replication listener is working while workflow is throwing exception. Below are the code and their log when try to run this code:-

private Logger log = LoggerFactory.getLogger(this.getClass());

@reference
private ResourceResolverFactory rrf;
private void performWorkflow(){
try {
Map<String, Object> authenticationInfo = new HashMap<String, Object>();
authenticationInfo.put(ResourceResolverFactory.SUBSERVICE, "datawrite");
ResourceResolver resourceResolver = rrf.getServiceResourceResolver(authenticationInfo);
Session session = resourceResolver.adaptTo(Session.class);
WorkflowSession wfSession = workflowService.getWorkflowSession(session);

WorkflowModel wfModel = wfSession.getModel("/var/workflow/models/custom-assets-activate-workflow");
if(wfModel != null){
WorkflowData wfData = wfSession.newWorkflowData(PayloadMap.TYPE_JCR_PATH, "/content/dam/image/image1.jpg");
log.debug("Starting workflow using model: {}",wfModel.getId());
wfSession.startWorkflow(wfModel, wfData);
}else{
log.warn("No workflow model found. Skipping transaction.");
}
} catch (WorkflowException ex) {
log.error("Error starting workflow.", ex);
} catch (LoginException e) {
// TODO Auto-generated catch block
log.error("Error starting workflow.", e);
}
}

 

log :-

05.01.2020 16:14:43.849 *DEBUG* [Thread-12] com.adobe.community.core.listeners.ReplicationNotificationListener Starting workflow using model: /var/workflow/models/custom-assets-activate-workflow
05.01.2020 16:16:46.026 *ERROR* [Thread-12] com.adobe.community.core.listeners.ReplicationNotificationListener Error starting workflow.
com.day.cq.workflow.WorkflowException: Cannot create workflow instance
at com.day.cq.workflow.impl.CQWorkflowSessionWrapper.startWorkflow(CQWorkflowSessionWrapper.java:303) [com.day.cq.workflow.cq-workflow-impl:6.2.12]
at com.day.cq.workflow.impl.CQWorkflowSessionWrapper.startWorkflow(CQWorkflowSessionWrapper.java:249) [com.day.cq.workflow.cq-workflow-impl:6.2.12]
at com.adobe.community.core.listeners.ReplicationNotificationListener.performWorkflow(ReplicationNotificationListener.java:95) [Event64.core:1.0.0.SNAPSHOT]
at com.adobe.community.core.listeners.ReplicationNotificationListener.handleEvent(ReplicationNotificationListener.java:70) [Event64.core:1.0.0.SNAPSHOT]
at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [org.apache.felix.eventadmin:1.4.10]
at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [org.apache.felix.eventadmin:1.4.10]
at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [org.apache.felix.eventadmin:1.4.10]
at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [org.apache.felix.eventadmin:1.4.10]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.jcr.AccessDeniedException: Access denied.
at org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissions(AccessManager.java:71) [org.apache.jackrabbit.oak-jcr:1.8.2]
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:295) [org.apache.jackrabbit.oak-jcr:1.8.2]
at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:264) [org.apache.jackrabbit.oak-jcr:1.8.2]
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:208) [org.apache.jackrabbit.oak-jcr:1.8.2]
at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) [org.apache.jackrabbit.oak-jcr:1.8.2]
at org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:264) [org.apache.jackrabbit.oak-jcr:1.8.2]
at com.adobe.granite.workflow.core.jcr.WorkflowBucketManager.createWorkflowInstanceNode(WorkflowBucketManager.java:206) [com.adobe.granite.workflow.core:2.0.168]
at com.adobe.granite.workflow.core.jcr.WorkflowManager.createWorkflowInstance(WorkflowManager.java:319) [com.adobe.granite.workflow.core:2.0.168]
at com.adobe.granite.workflow.core.WorkflowSessionImpl.startWorkflow(WorkflowSessionImpl.java:1587) [com.adobe.granite.workflow.core:2.0.168]
at com.day.cq.workflow.impl.CQWorkflowSessionWrapper.startWorkflow(CQWorkflowSessionWrapper.java:297) [com.day.cq.workflow.cq-workflow-impl:6.2.12]
... 12 common frames omitted

 

All this activity i am doing as admin user in my local, so i do not think any access related issue. I have created a system user for "datawrite" subservice and configured it in Apache Sling Service User Mapper Service and gave read and modify access in the top which means he has read and modify access to all the folders and nodes.

I also put AEM debugger in my eclipse and there i get error "com.day.cq.workflow.WorkflowException: Cannot create workflow instance".

Thanks!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies