title: Optional persistence unit in JPA (when using multiple persistence units)
body: <p>Does JPA support optional persistence units and if so how do I configure that?</p>
  
  <p>I do have one persistence unit which is my main database. </p>
  
  <p>Then I configured another one where I just read objects from the db to do some checks. To avoid messing around with transactions on multiple datasources I set the second datasource <code>jta="false"</code>. </p>
  
  <p>But I like to be able to check if a second datasource was defined at all and only use it if it is there. If it is not defined I'd like to simply skip my checks. </p>
  
  <p>The problem is that I can not find how to make this optional. If the second datasource is not configured I get a <code>New missing/unsatisfied dependencies</code> error from the deployment scanner in Jboss when my war is deployed: </p>
  
  <pre><code>service jboss.naming.context.java.secondDatasource (missing) dependents: [service jboss.persistenceunit."de.my.war#secondDatasource"] 
  </code></pre>
  
  <p>(Btw: I am using JBoss 7.1.0 and configured the datasources in standard.xml - if that info is of any relevance.)</p>
  
  <p>Any hints?</p>