I faced the same problem. After looking at several places here is how I dealt with it.
//function in some model/utility
function someFunction($em){
try{
//code which may throw exception and lead to closing of entity manager
}
catch(Exception $e){
//handle exception
return false;
}
return true;
}
//in controller assuming entity manager is in $this->em
$result = someFunction($this->em);
if(!$result){
$this->getDoctrine()->resetEntityManager();
$this->em = $this->getDoctrine()->getManager();
}
Hope this helps someone!