@PersistenceContext injection of EntityManager
<p>I am looking into this <a href="http://tomee.apache.org/examples-trunk/injection-of-entitymanager/README.html" rel="nofollow">EntityManager tutorial</a> and I understood that you either can describe your <code>EM</code> in <code>persistence.xml</code> or use annotations. 
So I created something similar to this class:     </p>

<pre><code>package org.superbiz.injection.jpa;

import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.Query;
import java.util.List;

@Stateful
public class Movies {

    @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
    private EntityManager entityManager;

    public void addMovie(Movie movie) throws Exception {
        entityManager.persist(movie);
    }

    public void deleteMovie(Movie movie) throws Exception {
        entityManager.remove(movie);
    }

    public List&lt;Movie&gt; getMovies() throws Exception {
        Query query = entityManager.createQuery("SELECT m from Movie as m");
        return query.getResultList();
    }
}
</code></pre>

<p>I got exception:</p>

<pre><code>    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class com.epam.rudenkov.controller.BookStore for component com.epam.rudenkov.controller.BookStore has errors: 
JBAS011440: Can't find a persistence unit named movie-unit in deployment \"book_store.war\""}}
</code></pre>

<p><strong>Questions:</strong></p>

<ul>
<li>Should I create also <code>persistence.xml</code>?</li>
<li>What is for <code>unitName</code>? </li>
</ul>