private void verifyContainerId(String containerId, String caseId) { String caseContainerId; try { caseContainerId = (new ByCaseIdContainerLocator(caseId)).locateContainer(containerId, null); } catch (IllegalArgumentException e) { throw new CaseNotFoundException(e.getMessage()); } KieContainerInstanceImpl taskContainer = context.getContainer(caseContainerId); List<KieContainerInstanceImpl> containersByAlias = context.getContainersForAlias(containerId); // The container id is either a non-existent one or is not a valid alias for the container id the task is associated with. Both scenarios should raise an exception. if (context.getContainer(containerId) == null && !containersByAlias.contains(taskContainer)) { throw new DeploymentNotFoundException("CaseId: " + caseId + " is not associated with the provided container id: " + containerId + " or its alias."); } }