Unable to trigger replication from custom workflow step
Hey everyone,
I am working on an AEM 6.5.17 and trying to trigger content replication to the publish instance from a custom workflow step. I have injected the Replicator service in my workflow process implementation, but when the step is executed, I am getting a NullPointerException when calling replicator.replicate(...).
Here is a simple code:
public class CustomReplicationStep implements WorkflowProcess {
@3214626
private Replicator replicator;
@9944223
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) {
String payloadPath = workItem.getWorkflowData().getPayload().toString();
try {
Session session = workflowSession.adaptTo(Session.class);
replicator.replicate(session, ReplicationActionType.ACTIVATE, payloadPath);
} catch (Exception e) {
log.error("Replication failed", e);
}
}
}
I registered this workflow properly in OSGI, and it appears in the workflow model, but the error suggests the replicator is null. I even tried switching to @586265, but it didn’t help.
Has anyone faced this before? Do I need to handle service injection differently inside workflow steps?
Thanks in advance!