title: java.lang.illegalstateexception unable to retrieve entitymanagerfactory for unitname null
body: <p>I write Entity.jar .It's EJB Module contain entity class and etitydao class. When i run it on GlassFish , i have error:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:138)
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:158)
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:151)
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:281)
      at com.styl.thincapayment.dao.impl.DataAccessImpl.insertToDatabase(DataAccessImpl.java:42)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
  </code></pre>
  
  <p><strong>I think it comes from persistence.xml . I put it wrong place. How to resolve this problem.</strong></p>
  
  <ul>
  <li><p>I put persistence file in entities/src/resources/persistence.xml . I use Maven to manage project</p></li>
  <li><p>Declaration EntityManager:</p>
  
  <p>@PersistenceContext(unitName="entities")</p>
  
  <p>protected EntityManager entityManager;</p></li>
  </ul>