title: Weblogic Server Upgrade: EJB3 JPA KODO: No persistence unit named 'em' is available in scope
body: <p>I have been wrestling with this error for last few days. Please someone point out what is going wrong.</p>
  
  <p>I have an EAR application in production on Weblogic Server 10.0 working just fine. When I deploy the same build EAR on Weblogic Server 10.3.4, I get an error:</p>
  
  <blockquote>
    <p>No persistence unit named 'em' is available in scope /projectEARName. Available persistence units: []  </p>
  </blockquote>
  
  <p>The application is an exploded EAR with exploded JAR and WAR. The JAR uses JPA (Kodo framework, which is the JPA RI in WebLogic) and EJB3. WAR uses JSF Framework.</p>
  
  <p>Project Final Build Folder Structure (Build using ANT; All Exploded; Which get deployed in WLS)</p>
  
  <ul>
  <li>EAR
  <ul>
  <li>JAR
  <ul>
  <li>Project's Classes</li>
  <li>META-INF
  <ul>
  <li>persistence.xml</li>
  <li>ejb-jar.xml</li>
  <li>weblogic-ejb-jar.xml</li>
  </ul></li>
  </ul></li>
  <li>war
  <ul>
  <li>Project's UI Files</li>
  <li>WEB-INF
  <ul>
  <li>lib</li>
  <li>classes</li>
  </ul></li>
  </ul></li>
  <li>META-INF
  <ul>
  <li>weblogic-application.xml</li>
  <li>application.xml</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&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="PU" transaction-type="JTA"&gt;
  &lt;provider&gt;kodo.persistence.PersistenceProviderImpl&lt;/provider&gt;
  &lt;jta-data-source&gt;SMDS&lt;/jta-data-source&gt;
  &lt;class&gt;com.aaa.bbbb.domainobjects.cccc&lt;/class&gt;
  &lt;class&gt;com.aaa.bbbb.domainobjects.dddd&lt;/class&gt;
  &lt;class&gt;com.aaa.bbbb.domainobjects.eeee&lt;/class&gt;
  &lt;properties&gt;
      &lt;property name="kodo.jdbc.SQLFactory" value="BatchLimit=-1, SupportsUnion=true"/&gt;
      &lt;property name="kodo.DataCache" value="true(CacheSize=5000, SoftReferenceSize=0)"/&gt;
      &lt;property name="kodo.RemoteCommitProvider" value="sjvm"/&gt;
      &lt;property name="kodo.Log" value="DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=TRACE"/&gt;
  &lt;/properties&gt; 
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>EJB Facade Class (which uses EntityManager)</p>
  
  <pre><code>@Stateless(name="XYZFacade", mappedName="XYZFacade")
  public class XYZFacadeBean implements XYZFacade {
      @PersistenceContext
      private EntityManager em;
  }
  </code></pre>
  
  <p>I think the issue might be due to the change in JARs in modules folder in Weblogic installation folder. Any ideas, anyone ?</p>