title: How to edit jdoconfig.xml and persistence.xml so JPA saves to appengine datastore
body: <p>Using the Google Eclipse Plugin, my project automatically comes with two files inside the META-INF folder: <code>jdoconfig.xml</code> and <code>persistence.xml</code>. Per the instructions on <a href="https://developers.google.com/appengine/docs/java/datastore/jpa/overview" rel="nofollow">https://developers.google.com/appengine/docs/java/datastore/jpa/overview</a>, my persistence file is supposed to have the following line for jpa datastore storage:</p>
  
  <pre><code>&lt;provider&gt;org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider&lt;/provider&gt;
  </code></pre>
  
  <p>But when I open the persistence file I found</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_1_0.xsd" version="1.0"&gt;
  
      &lt;persistence-unit name="transactions-optional"&gt;
          &lt;provider&gt;org.datanucleus.api.jpa.PersistenceProviderImpl&lt;/provider&gt;
          &lt;properties&gt;
              &lt;property name="datanucleus.NontransactionalRead" value="true"/&gt;
              &lt;property name="datanucleus.NontransactionalWrite" value="true"/&gt;
              &lt;property name="datanucleus.ConnectionURL" value="appengine"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>and the <code>jdoconfig.xml</code> file is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig"&gt;
  
     &lt;persistence-manager-factory name="transactions-optional"&gt;
         &lt;property name="javax.jdo.PersistenceManagerFactoryClass"
             value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/&gt;
         &lt;property name="javax.jdo.option.ConnectionURL" value="appengine"/&gt;
         &lt;property name="javax.jdo.option.NontransactionalRead" value="true"/&gt;
         &lt;property name="javax.jdo.option.NontransactionalWrite" value="true"/&gt;
         &lt;property name="javax.jdo.option.RetainValues" value="true"/&gt;
         &lt;property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/&gt;
     &lt;/persistence-manager-factory&gt;
  &lt;/jdoconfig&gt;
  </code></pre>
  
  <p>With those default contents, JPA has not been saving to my datastore. So I edit the <code>persistence.xml</code> file to look like this</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_1_0.xsd" version="1.0"&gt;
  
      &lt;persistence-unit name="transactions-optional"&gt;
          &lt;provider&gt;org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider&lt;/provider&gt;
          &lt;properties&gt;
              &lt;property name="datanucleus.NontransactionalRead" value="true"/&gt;
              &lt;property name="datanucleus.NontransactionalWrite" value="true"/&gt;
              &lt;property name="datanucleus.ConnectionURL" value="appengine"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>How should I change the <code>jdoconfig.xml</code> file? Right now, with my changes to <code>persistence</code> but <code>jdoconfig</code> as is, I am getting a huge error trace.</p>
  
  <p>redacted error:</p>
  
  <pre><code>java.lang.ExceptionInInitializerError
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
      at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
  
  …
  …
  ...
  
  Caused by: javax.persistence.PersistenceException: No persistence providers available for "transactions-optional" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:180)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:70)
  </code></pre>