title: Cannot acquire data source whit PostgreSql. Can't use JPA EntityManager
body: <p>I have the next problem:</p>
  
  <p>I am doing a project using JPA and Restfull whit netbeasn and postgres, I have the following persistence</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt;
    &lt;persistence-unit name="PruebaPersitenciaPU" transaction-type="JTA"&gt;
      &lt;jta-data-source&gt;data_cotratacion&lt;/jta-data-source&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
      &lt;properties/&gt;
    &lt;/persistence-unit&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And also the following code using the EntityManager:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@GET
      public String crearPersona(
              @QueryParam("id") String id,
              @QueryParam("name") String name,
              @QueryParam("gender") String gender,
              @QueryParam("date") String date){
          Persona p = new Persona();
          p.setId(id);
          p.setName(name);
          p.setGender(gender);
          p.setDate(stringToDate(date));
          try {        
              EntityManagerFactory emf = Persistence.createEntityManagerFactory("PruebaPersitenciaPU");
              EntityManager em = emf.createEntityManager();
              
              em.getTransaction().begin();
              em.persist(p);
              em.getTransaction().commit();
          
              return "Usuario Creado "+id;
          } catch (Exception e) {
              return "Usuario no creado error: "+e;
          }
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>but try this sends me this error:</p>
  
  <blockquote>
    <p>Usuario no creado error: javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException Exception Description: Cannot acquire data source [data_cotratacion]. Internal Exception: javax.naming.NamingException: Lookup failed for 'data_cotratacion' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: data_cotratacion not found]</p>
  </blockquote>