fixed acquisition of the entityManager