title: Java Play access entities from persistence.xml
body: <p>I am continuing to get this error when running my play application:</p>
  <pre><code>play.api.PlayException: Execution exception[[CompletionException: java.lang.IllegalArgumentException: Unknown entity:
  </code></pre>
  <p>I have created my play application to have this kind of structure</p>
  <pre><code>- app-name
    - app
    - conf
      - META-INF/persistence.xml
      - application.conf
    - modules
      - dao
        - src/main/java/package
          - dao
            - util/DaoModule
            - Repository.java
            - RepositoryImpl.java
          - domain.dbo.entities
            {All the entities}
      - service
  </code></pre>
  <p>where persistence.xml has this structure:</p>
  <pre><code>&lt;persistence [some attributes]&gt;
      &lt;persistence-unit name=&quot;defaultPersistenceUnit&quot; transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;properties&gt;...&lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  <p>and application conf has:
  <code>jpa.default=defaultPersistenceUnit</code></p>
  <p>It seems that the issue is persistence.xml is not visible to the dao module so the persistence unit cannot pick up the entities in the domain.dbo.entities package.  The error goes away when in persistence xml I include each entity like</p>
  <p><code>&lt;class&gt;package.domain.dbo.entities.EntityName&lt;/class&gt;</code></p>
  <p>But I would like for the entities to be picked up using the @Entity annotation, which works when they are under the app directory.</p>
  <p>I have tried the following solutions, which have not worked:</p>
  <ul>
  <li>moving the META-INF folder into the dao module</li>
  <li>adding play.modules.enabled += modules.Dao</li>
  <li>in persistence.xml set packagesToScan to be the entities package</li>
  </ul>
  <p>It seems that the entities package is not in the scope of the persistence unit, and I do not know how to resolve this. Is there a way to  register a persistence unit with a module so JPAApi can pick up the entities?  How can entities in a different module be registered with the persistence unit?</p>