Restart process throwing exception

I have service task throwing exception in some scenario so the process is terminated, I am trying to restart the process from the failed service task but the below call is throwing the exception : org.camunda.bpm.engine.BadUserRequestException: Historic process instance cannot be found: historicProcessInstanceId is null

camunda.getRuntimeService().restartProcessInstances()
.startBeforeActivity()
.processInstanceIds()
.execute();

Looking at the docs : Process Instance Restart | docs.camunda.org, it says “provided that the history level is set to FULL” so I even tried setting the full history log like below but still getting the same error.

	ProcessEngineConfiguration
			.createStandaloneInMemProcessEngineConfiguration()
			.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
			.buildProcessEngine();

Am I missing something here? I didn’t see specific configuration needed for restart process to be able to work.

Thank you in advance.

Is there any specific pre-requisites which is not documented for restartProcessInstances() to work

Hi @explorer
I do not know about some speific pre-requesties except stated in the link.

After a process instance termination, its historic data still exists and can be accessed to restore a process instance, provided that the history level is set to FULL.

Since you set the history level to FULL then as the next step I would check is the instane is terminated and present in historic tables at the moment when yout try to restart it.