title: How to setup a JTA data source in EclipseLink/JPA 2.0 in an Java EE 6 application for derby embedded database?
body: <p>I am not able to find ecbDB JTA data source in the unit test.</p>
  
  <p>For RESOURCE_LOCAL the same persistence.xml works. Only within an EJB container it fails to locate a JTA data source.</p>
  
  <p>I get the following exception when the unit test is executed..</p>
  
  <pre><code>SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
  java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'ecbDB' in SerialContext  [Root exception is javax.naming.NameNotFoundException: ecbDB not found]
   at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.&lt;init&gt;(PersistenceUnitInfoImpl.java:111)
  </code></pre>
  
  <p>Here is persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence
    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_2_0.xsd"
      version="2.0"&gt;
  
      &lt;persistence-unit name="ecbPU" transaction-type="JTA"&gt;
          &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;jta-data-source&gt;ecbDB&lt;/jta-data-source&gt;
          &lt;mapping-file&gt;META-INF/orm.xml&lt;/mapping-file&gt;
  
          &lt;properties&gt;
              &lt;property
                name="javax.persistence.jdbc.driver"
                value="org.apache.derby.jdbc.EmbeddedDriver" /&gt;
              &lt;property
                name="javax.persistence.jdbc.url"
                value="jdbc:derby:target/ecbDB;create=true" /&gt;
  
              &lt;!-- EclipseLink 2.0 properties --&gt;
              &lt;property name="eclipselink.ddl-generation" value="drop-and-create-tables" /&gt;
              &lt;property name="eclipselink.ddl-generation.output-mode"
                        value="sql-script" /&gt;
              &lt;!-- &lt;property name="eclipselink.ddl-generation.output-mode" value="database"
               /&gt; --&gt;
              &lt;property name="eclipselink.application-location" value="./target/ddl" /&gt;
              &lt;property name="eclipselink.create-ddl-jdbc-file-name"
                        value="create.sql" /&gt;
              &lt;property name="eclipselink.drop-ddl-jdbc-file-name" value="drop.sql" /&gt;
              &lt;property name="eclipselink.logging.level" value="ALL" /&gt;
              &lt;property name="eclipselink.logging.file" value="./target/eclipselink.logs" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>