Silex Doctrine "The EntityManager is closed" after Doctrine Exception
<p>I am registering Doctrine in Silex in this way:</p>

<pre><code>    // Doctrine
    $this-&gt;register(new DoctrineServiceProvider(), array(
        'db.options' =&gt; $this['config']['doctrine']['db.options']
    ));
    $this-&gt;register(new DoctrineOrmServiceProvider());
    $this['orm.em.options'] = $this['config']['doctrine']['orm.em.options'];
</code></pre>

<p>If I insert a duplicated row then I get this exception:</p>

<blockquote>
  <p>Integrity constraint violation: 1062 Duplicate entry</p>
</blockquote>

<p>I have catched this exception using try/catch. If later I try to use again Doctrine, now always this exception is shown:</p>

<blockquote>
  <p>The EntityManager is closed.</p>
</blockquote>

<p>If I try reload the EntityManager following these steps (<a href="https://stackoverflow.com/questions/14258591/the-entitymanager-is-closed">The EntityManager is closed</a>) :</p>

<pre><code>    if (!$app['orm.em']-&gt;isOpen()) {
        $app['orm.em'] = $app['orm.em']-&gt;create(
                $app['orm.em']-&gt;getConnection(), $app['orm.em']-&gt;getConfiguration(), $app['orm.em']-&gt;getEventManager()
        );
    }
</code></pre>

<p>But now this exception is shown:</p>

<blockquote>
  <p>Cannot override frozen service "orm.em"</p>
</blockquote>

<p>How can I use Doctrine provider in Silex after a Doctrine exception is happened?</p>

<p>Thanks.</p>