@martin.grofcik But I get this error whenever I restart my tomcat. After 2-3 restarts all timer entity error gets cleared and it starts working fine.
For deleting existing model & deployment, I am using the following code.
<java>
public String deleteModel(String modelName, String processName) {
RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
RuntimeService runtimeService = ProcessEngines.getDefaultProcessEngine().getRuntimeService();
HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
List<Model> models = repositoryService.createModelQuery().modelName(modelName).list();
if (models != null && models.isEmpty()) {
return "Model Not Found";
}
for (Model model : models) {
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().
processDefinitionKey(processName).list();
for (ProcessDefinition processDefinition : processDefinitions) {
try {
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(processName).list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
runtimeService.deleteProcessInstance(historicProcessInstance.getId(), "Model Deleted");
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
} catch (Exception e) {
LOGGER.error("Error deleting model", e);
}
try {
repositoryService.deleteDeployment(processDefinition.getDeploymentId(), true);
} catch (Exception e) {
LOGGER.error("Error deleting model", e);
}
}
try {
repositoryService.deleteModel(model.getId());
} catch (Exception e) {
LOGGER.error("Error deleting model", e);
}
}
return "Deleted Successfully";
}
</java>
Is there some issue in the above code which is leading to the current exceptions.