title: Two Persistence Unit in one Persistence.xml
body: <p>We created some libraries that all our projects will use, this libraries will provide the basic functionality of all our systems (login, some manage, etc). But the application itself could use another database.</p>
  
  <p>What we did was to create the Persistence.xml with two persist units. And package all the core library entities in a jar called "LN-model.jar" and all of the entities of out test app in "App-model.jar". But for some reason we still obtain the following message.</p>
  
  <blockquote>
    <p>Could not resolve a persistence unit corresponding to the persistence-context-ref-name [x.x.x.x.listener.InicializadorListener/em] in the scope of the module called [gfdeploy#/Users/zkropotkine/WORK/SeguridadCore/dist/gfdeploy/SeguridadCore-war_war]. Please verify your application.</p>
  </blockquote>
  
  <p>Here's our Persistence.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
  
  &lt;persistence-unit name="x" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/x&lt;/jta-data-source&gt;
      &lt;jar-file&gt;App-model.jar&lt;/jar-file&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
      &lt;/properties&gt; 
  &lt;/persistence-unit&gt;
  
  &lt;persistence-unit name="y" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/y&lt;/jta-data-source&gt;
      &lt;jar-file&gt;LN-model.jar&lt;/jar-file&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
      &lt;properties/&gt;
  &lt;/persistence-unit&gt; 
  </code></pre>
  
  <p></p>
  
  <p>By the way we put the Persistence.xml in a jar, that we add to our Enterprise Project (EAR).</p>