title: Empty EntityManager in Java EE bean on JBoss 5.1
body: <p>I'm a newbie in Java EE. This is the first project I'm trying to do and I have a problem that I just can't solve.</p>
  
  <p>I've created three projects: slowka-beans (EJB), slowka-persistance (JPA) and slowka-web(JSF). After deploying them I can't get access to persistence unit - the EntityManager is null. Everything works fine - I can create beans, inside them instantiate entity classes and show them on JSF page. But how can I store them in the DB? I have MySQL database configured on JBoss site.</p>
  
  <p>The code that I have looks following:
  LanguagesManager.java (in slowka-beans)</p>
  
  <pre><code>@Stateless
  public class LanguagesManager implements LanguagesManagerLocal {
  
      @PersistenceContext(unitName="slowka-persistance")
      private EntityManager em;
  
      public LanguagesManager() {
          System.out.println("LanguagesManagerBean constructor");
      }
  
      public String getWorking() {
          if(em == null) {
              System.out.println("Not working...");
              return "Not working...";
          } else {
              System.out.println("It's ALIVE!");
              return "It's ALIVE!";
          }
      }
  }
  </code></pre>
  
  <p>persistence.xml (slowka-persistance):</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="slowka-persistance"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;jta-data-source&gt;java:/PraktykiDS&lt;/jta-data-source&gt;
          &lt;class&gt;pl.edu.uj.sobczak.szymon.Language&lt;/class&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>Deploying this on server doesn't cause any exceptions. but I've spotted the following warnings in server's output:</p>
  
  <pre><code>23:02:23,801 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=slowka.ear/slowka-persistance.jar#slowka-persistance
  23:02:23,803 INFO  [Ejb3Configuration] Processing PersistenceUnitInfo [
      name: slowka-persistance
      ...]
  23:02:23,804 WARN  [Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
  (... trimmed ...)
  23:02:23,868 INFO  [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitName=slowka.ear/slowka-persistance.jar#slowka-persistance
  23:02:23,868 WARN  [SessionFactoryObjectFactory] InitialContext did not implement EventContext
  </code></pre>
  
  <p>Every time I'm accessing <code>LanguagesManager::getWorking()</code> from JSP i'm getting "Not working..." output.</p>
  
  <p>I've created the project in Eclipse, JPA is using EclipseLink. I've tried both - EclipseLink 1.1.4 and 2.1.0 with the same result.</p>
  
  <p>Can please you help me?</p>