title: google app engine: problem getting objects from datastore in a task
body: <p>My application constructs a <code>Parent</code> object in a static factory, along with it's predetermined <code>Child</code>ren, and then starts up tasks to run some computation on the <code>Child</code>ren, like so:</p>
  
  <pre><code>public static Parent make(User owner, List&lt;Integer&gt; data, int size) {
          Parent result = new Parent(owner,data,size);
          PersistenceManager pm = PersistenceSource.get();
          Transaction tx = pm.currentTransaction();
  
          try {
              tx.begin();
              result = pm.makePersistent(result);
              for (int i=0; i&lt;size; pm.makePersistent(new Child(result,i++)));
              pm.close();
              tx.commit();
          } finally {
              if (tx.isActive()) { tx.rollback(); result=null; }
          }
  
          if (result!=null) {
              Queue q = QueueFactory.getDefaultQueue();
              for (Child c : result.getChild()) {
                  q.add(url("/task/child").param("key", KeyFactory.keyToString(c.getKey())).method(Method.PUT));
              }
          }
          pm.close();
          return result;
      }
  </code></pre>
  
  <p>however in the actual task</p>
  
  <pre><code>public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
      PersistenceManager pm = PersistenceSource.get();
  
      Child c = pm.getObjectById(Child.class, KeyFactory.stringToKey(request.getParameter("key"))); //...
  </code></pre>
  
  <p>It dies trying to find the object:</p>
  
  <pre><code>Could not retrieve entity of kind Child with key Child(24)
  org.datanucleus.exceptions.NucleusObjectNotFoundException: Could not retrieve entity of kind Child with key Child(24)
  </code></pre>
  
  <p>Any insights?  Also, if it matters, the Parent-child relationship is defined by the parent as a field in the child (hence construction with the parent as an arg).</p>