Investigating this issue, I created a workaround. It is not ideal, but at least gets the job done. Instead of performing a query through the repository service, I perform it using a query in the runtime service. Of course, this is far from ideal, since in a production environment it means to search the whole process definitions database - but then again, it will probably not be so huge as to cause a significant performance impact.
So in the try clause, I would write this line instead of the one above:
processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).list().get(0);