title: datanucleus complaining about class not being enhanced, but when run 2nd time works fine.
body: <p>I am trying to make datanucleus, work with Mongodb (using JDO). After successful </p>
  
  <pre><code>mvn clean compile
  mvn exec:java 
  </code></pre>
  
  <p>when I run first time it fails with </p>
  
  <pre><code>caused by: org.datanucleus.exceptions.NucleusUserException: Found Meta-Data for class com.samples.jdo.mongodb.Account but this class is either not enhanced or you have multiple copies of jdo-api.jar in your CLASSPATH!! Make sure all persistable classes are enhanced before running DataNucleus and/or the CLASSPATH is correct.
  </code></pre>
  
  <p>but if I run again it works fine and I can see data getting persisted in mongodb too. </p>
  
  <pre><code>        // Create a PersistenceManagerFactory for this datastore
      PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("datanucleus.properties", this.getClass().getClassLoader());
      JDOMetadata jdomd = pmf.newMetadata(); 
      PackageMetadata pmd = jdomd.newPackageMetadata("com.samples.jdo.mongodb");
      ClassMetadata cmd1 = pmd.newClassMetadata(Account.class);
      cmd1.setTable("Account").setIdentityType(javax.jdo.annotations.IdentityType.DATASTORE);
      cmd1.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
  
      ClassMetadata cmd2 = pmd.newClassMetadata(Login.class); 
      cmd2.setTable("LOGIN").setIdentityType(javax.jdo.annotations.IdentityType.DATASTORE);
      cmd2.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
  
  
          PersistenceManager pm = pmf.getPersistenceManager();
          Account acct = new Account("firstname","lastname", 3);
          Login login = new Login("flastname", "xxxx");
          acct.setLogin(login);
  
          final JDOEnhancer enhancer = JDOHelper.getEnhancer(); 
          enhancer.setVerbose(true); 
          enhancer.registerMetadata(jdomd);
          enhancer.setClassLoader(this.getClass().getClassLoader());
          String[] classes = {"com.samples.jdo.mongodb.Account","com.samples.jdo.mongodb.Login" };
          enhancer.addClasses(classes); 
          enhancer.enhance(); 
  
          pmf.registerMetadata(jdomd);            
          pm.makePersistent(acct);
  </code></pre>
  
  <p>any ideas?</p>
  
  <p>Thanks</p>