How can get the id of the next activity with the id of current activity?

Hi
my flowable version:6.0.1
As it said in title, I tried the following way

private String getNextActivityId(String currentActivityId,String processDefinitionId) {
    Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
    Association association = process.findAssociationsWithSourceRefRecursive(currentActivityId).get(0);
    FlowElement targetElement = process.getFlowElement(association.getTargetRef(), false);
    return targetElement.getId();
}

but got exception :
org.flowable.engine.common.api.FlowableException: Found Flowable 5 process definition, but no compatibility handler on the classpath

at org.flowable.engine.impl.util.Flowable5Util.getFlowable5CompatibilityHandler(Flowable5Util.java:130)
at org.flowable.engine.impl.util.ProcessDefinitionUtil.getProcess(ProcessDefinitionUtil.java:55)

Hi,

the problem is:

public static Process getProcess(String processDefinitionId) {
    if (Context.getProcessEngineConfiguration() == null) {
        return Flowable5Util.getFlowable5CompatibilityHandler().getProcessDefinitionProcessObject(processDefinitionId);

As you see in the case when you call > getProcess without Context process engine configuration set, the definition is handled as Flowable5 defintion. And apparently you are not using Flowable5 compatibility handlers.

The solution could be to set Context.processEngineConfiguration before the method call. (Context.setProcessEngineConfiguration or just run the call in the command which sets context automatically → I would prefer this one: org.flowable.engine.ManagementService#executeCommand(org.flowable.engine.impl.interceptor.Command))

Regarding next activity. It is hard to guess what will be next process instance activity before completing current one (error/variableChange/interruption…).

Regards
Martin

I see what you mean.Many thanks for the prompt reply.