title: JPA createEntityManagerFactory "Unknown Source" error (non-J2EE)
body: <p>I can't find what's wrong: many people seem to have issues with creating a EntityManagerFactory using the PU name. But I've checked all the suggestions, and none helped so far. 
  I'm trying to build my first JavaFX2 app. It is a small dictionary application, originally built on the Netbeans Application framework (by extending the default "Master-Detail" generated classes). It uses a SQLite db.  </p>
  
  <p>I'm now porting it over from there to another (JavaFX2-enabled) project. I first set out to rebuild the JPA persistence stuff in the new app. As far as I can see, I have everything in place: META-INF/persistence.xml with all the necessary entity classes declarated, using the same DB connection as the original application. </p>
  
  <p>I added <em>eclipselink-2.3.0.jar</em>; <em>eclipselink-javax.persistence-2.0.jar</em> and <em>eclipselink-jpa-modelgen-2.3.0.jar</em> to the project. </p>
  
  <p>Instead of the Application Context I use a simple Properties class to hold the data (such as queries) that previously went in the .properties files. </p>
  
  <p>This is the test class:</p>
  
  <pre class="lang-java prettyprint-override"><code>    package ithildinfx;
  
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.Group;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.stage.Stage;
      import javafx.beans.property.StringProperty;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
  
      public class IthildinFX extends Application {
         private void init(Stage primaryStage) {
            entityManager = javax.persistence.Persistence.createEntityManagerFactory("IthildinFXPU").createEntityManager(); 
            entryQuery = entityManager.createQuery(Properties.entryQuery).setParameter("gloss", "a%"); 
            entryList = entryQuery.getResultList();
  
            Group root = new Group();
            primaryStage.setScene(new Scene(root));
            (TableColumn definitions)
            (TableView code)
            root.getChildren().add(tableView);
         } 
  
         @Override 
         public void start(Stage primaryStage) throws Exception {
            init(primaryStage);
            primaryStage.show();
         }
  
         public static void main(String[] args) { 
            launch(args); 
         }
  
         private javax.persistence.EntityManager entityManager;
         private java.util.List&lt;ithildinfx.Entry&gt; entryList;
         private javax.persistence.Query entryQuery;
     }
  </code></pre>
  
  <p>And this is the contents of persistence.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;persistence version="2.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_2_0.xsd"&gt;
        &lt;persistence-unit name="IthildinFXPU" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;class&gt;ithildinfx.Dataclass&lt;/class&gt;
          &lt;class&gt;ithildinfx.Metadata&lt;/class&gt;
          &lt;class&gt;ithildinfx.Translation&lt;/class&gt;
          &lt;class&gt;ithildinfx.Entry&lt;/class&gt;
          &lt;class&gt;ithildinfx.TrMd&lt;/class&gt;
          &lt;class&gt;ithildinfx.Language&lt;/class&gt;
          &lt;properties&gt;
            &lt;property name="javax.persistence.jdbc.url" value="jdbc:sqlite:lib/db/ithildin-13-11-11.db"/&gt;
            &lt;property name="javax.persistence.jdbc.password" value=""/&gt;
            &lt;property name="javax.persistence.jdbc.driver" value="org.sqlite.JDBC"/&gt;
            &lt;property name="javax.persistence.jdbc.user" value=""/&gt;
          &lt;/properties&gt;
        &lt;/persistence-unit&gt;
      &lt;/persistence&gt;
  </code></pre>
  
  <p>One of the suggestions that I read here on StackOverflow was to add this line to <em>manifest.mf</em>:</p>
  
  <pre><code>    Meta-Persistence: META-INF/persistence.xml
  </code></pre>
  
  <p>and, possibly:</p>
  
  <pre><code>    JPA-PersistenceUnits: IthildinFXPU
  </code></pre>
  
  <p>But neither made any difference. </p>
  
  <p>This is the output that I invariably get:</p>
  
  <pre><code>Building jar: /Users/luthien/NetBeansProjects/IthildinFX/dist/IthildinFX.jar
  Copy libraries to /Users/luthien/NetBeansProjects/IthildinFX/dist/lib.
  Building jar: /Users/luthien/NetBeansProjects/IthildinFX/dist/IthildinFX.jar
  Detected JavaFX Ant API version 1.1
  Deleting: /Users/luthien/NetBeansProjects/IthildinFX/dist/IthildinFX.jar
  Deleting: /Users/luthien/NetBeansProjects/IthildinFX/dist/lib/IthildinFX.jar
  Deleting: /Users/luthien/NetBeansProjects/IthildinFX/dist/README.TXT
  Skip jar copy to itself: IthildinFX.jar
  Skip jar copy to itself: lib/eclipselink-2.3.0.jar
  Skip jar copy to itself: lib/eclipselink-javax.persistence-2.0.jar
  Skip jar copy to itself: lib/eclipselink-jpa-modelgen-2.3.0.jar
  Skip jar copy to itself: lib/sqlite-jdbc-3.7.2.jar
  jfx-deployment:
  jar:
  run:
  Exception in Application start method
  java.lang.NullPointerException
      at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getProviderNames(Unknown Source)
      at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(Unknown Source)
      at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
      at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
      at ithildinfx.IthildinFX.init(IthildinFX.java:29)
      at ithildinfx.IthildinFX.start(IthildinFX.java:109)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:298)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:136)
      at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:108)
  JavaFX application launcher: calling System.exit
  jfxsa-run:
  BUILD SUCCESSFUL (total time: 5 seconds)
  </code></pre>
  
  <p>The libraries seem to all be in the right place - in any case, they are in the same place as they are in the first application. It might be that the Netbeans Application framework does some scary voodoo under the bonnet, but I really don't know how to figure that out.</p>
  
  <p>Does anyone know of a reason why it can't seem to find the PU?</p>
  
  <p>Thanks in advance!
  Luthien</p>