title: Multiple persistence units in Wildfly?
body: <p>Is it possible to have two persistence units in a Wildfly (9.0.2) application?</p>
  
  <p>I get "WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "jasper-web.war".  Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit."</p>
  
  <p>I have <code>unitName</code> specified in the <code>@PeristenceContext</code> annotations. I read somewhere I could disable</p>
  
  <pre><code>&lt;!--
  &lt;subsystem xmlns="urn:jboss:domain:jpa:1.1"&gt;
      &lt;jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/&gt;
  &lt;/subsystem&gt;
  --&gt;
  </code></pre>
  
  <p>in <code>standalone.xml</code>. This removed the error message, but also disabled injection of entityManagers (null pointer referencing them in code)</p>
  
  <p>I have tried to split the persistence units over two different ejb-jars, each with their own persistence.xml, but as they're still included in the same war, Wildfly still complains.</p>
  
  <p>The the two persistence units are used with hibernate, one with a postgresql database and one with a ucanaccess driver for ms access. They both work separately.</p>